-
Notifications
You must be signed in to change notification settings - Fork 12
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
Polymorphism (oneOf) with pydantic union discriminator #31
Comments
In addition to this issue with serializers this use case doesn't seem to work properly in models either. For me, on v0.3.3, I'm not able to create a migration if I use a
|
@henribru I have played around a bit with As a workaround for the time being I can suggest using a |
This PR is related to #31 This PR adds the support of typing.Annotated[...] expressions, both through schema= attribute or field annotation syntax; though I find the schema=typing.Annotated[...] variant highly discouraged. The current limitation is not in the field itself, but in possible Annotated metadata -- practically it can contain anything, and Django migrations serializers could refuse to write it to migrations. For most relevant types in context of Pydantic, I wrote the specific serializers (particularly for pydantic.FieldInfo, pydantic.Representation and raw dataclasses), thus it should cover the majority of Annotated use cases
I have the following pydantic models:
Now I define a new field
value_complex
in one of my serializers:I'm not sure if this issue is related to django-pydantic-field or drf-spectacular.
The generated Open API 3 Schema is invalid.
Regarding https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
oneOf
should have a list of$ref
and those 3 pydantic models should be defined in#/components/schemas/
The text was updated successfully, but these errors were encountered: