-
- Notifications
You must be signed in to change notification settings - Fork 8.2k
V1 models for response and body #10223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| exclude_none=exclude_none, | ||
| ) | ||
| except AttributeError: | ||
| return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if there is a better way to handle the case where there is a container of model instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isinstance()?
if isinstance(value, dict): ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for Python 3.11+, I expect its zero-overhead exception handling to be a bit more efficient. In case that's neglectable, an if/else branch with isinstance might be more readable.
| Any progress on this? Looks like it's been unchanged for almost a month. |
This comment was marked as outdated.
This comment was marked as outdated.
| Any update on this PR? I'm also blocked by the same issue. |
| This would really help large projects migrate to pydantic v2! |
| Any update ? |
| Any update? |
1 similar comment
| Any update? |
| Any update on this? FastAPI still supports Pydantic v1 is a fundamentally incorrect statement while this remains open, and we will not upgrade to pydantic v2 or fastapi 0.100 while this remains open. Otherwise there is no path to a smooth transition to v2, the entire repo must be upgraded in one go, defeating the purpose behind pydantic.v1 usage. https://fastapi.tiangolo.com/release-notes/#pydantic-v1
|
| Any update ? |
@tiangolo thoughts on this? |
| Looks like this will work for serialization/deserialization but needs additional work for schema generation: In this case the v2 schema generation is looking at the |
| @chbndrhnns, thanks for you contribution! Or, is there anybody who is willing to take this over and work on it? |
52de629 to 00dd5c6 Compare | For now, I updated the code to have passing tests. |
| Schema generation seems a bit more tricky: FastAPI now needs to handle both Pydantic v1 and v2 models simultaneously when running with Pydantic v2 installed. This is fundamentally different from the previous situation: Before: FastAPI only needed to handle one version of Pydantic models (v1) |
d77bd92 to 30e7a18 Compare | @YuriiMotov How do you suggest to proceed here? |
| This pull request has a merge conflict that needs to be resolved. |
| @YuriiMotov I am willing to rebase if we have a clear path to merging |
I think there is no need for this now. |
| Thanks for the interest and effort here! This was covered by #14168, which was just released in FastAPI 0.119.0. 🎉 That adds support for Given that, I'll close this one now. Thanks for the effort and interest and thanks all for the discussions! 🍰 |
No description provided.