You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With pydantic<2 parameters are correctly parsed as int and UUID if an appropriate string is passed, with pydantic 2 they're always interpreted as str, I presume this will work the same way with all other types that you can pass into path parameters.
I also observed the same behavior with query, so I assume it behaves the same way with all FastAPI parameters (headers, body, etc).
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.110.0
Pydantic Version
1.10.14 / 2.6.3
Python Version
Python 3.11.5
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Pydantic v2 switched to union_mode='smart' as the default, which in cases like this will always prefer str (since it's an exact type match).
It's also necessary to do this in any dependencies (as far as I can tell, type annotations set on direct path parameters and function parameters of dependencies aren't shared).
Discussed in #11250
Originally posted by ThirVondukr March 5, 2024
First Check
Commit to Help
Example Code
Description
With pydantic<2 parameters are correctly parsed as int and UUID if an appropriate string is passed, with pydantic 2 they're always interpreted as str, I presume this will work the same way with all other types that you can pass into path parameters.
I also observed the same behavior with query, so I assume it behaves the same way with all FastAPI parameters (headers, body, etc).
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.110.0
Pydantic Version
1.10.14 / 2.6.3
Python Version
Python 3.11.5
Additional Context
No response
The text was updated successfully, but these errors were encountered: