-
-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Labels
Description
Why do we need this improvement?
There were some steps made towards support of discriminators for Pydantic, unfortunately those don't bring full support of that feature.
Generated code should follow Pydantic's way of using Unions with discriminators described.
Current code will serialize objects correctly, but Pydantic is not able to find a correct resolution during deserialization because of the missing wiring in the code.
How will this change help?
Discriminated objects will be correctly deserialized by Pydantic.
Screenshots
No response
How could it be implemented/designed?
I do have a PR ready for it.
it is a 2-fold solution:
- it requires changes in the "container" field (so any field having
A | B, whereAandBare distinguished by discriminator).Unionor|must be wrapped inAnnotatedwithField(discriminator=...)provided. - discriminator field in the object must be
Literal.
🚧 Breaking changes
Yes
👀 Have you checked for similar open issues?
- I checked and didn't find a similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue?
Yes I am willing to submit a PR!
Reactions are currently unavailable