-
Notifications
You must be signed in to change notification settings - Fork 58
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
Not supported specify nullable types via anyOf #84
Comments
Is there any annotation in your backend so that "last_name": {
"type": "string",
"nullable": true,
"title": "Last Name"
} |
After talking to the backend team, there is an option to add nullable, but the type will also be set via anyOf: "last_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"nullable": true,
"title": "Last Name"
} So far, the only solution to the problem seems to me to support setting nullable type via anyOf. |
@Carapacik This feature looks more difficult than adding a flag. I think it is better to be implemented by a maintainer, because you need a good understanding of the package structure. What do you think about it? |
Already think about that in #5 |
Found a workaround using a self-describing class on the backend: Annotated[Union[UUID | SkipJsonSchema[None]], Field(json_schema_extra=lambda x: x.pop('default', None))] |
The new pydantic 2.1 on backend (Python, FastApi) describes nullable types in the anyOf specification. It would be nice to support this way of specifying a nullable type.
Small example:
Result:
Expected result:
OpenApi:
The text was updated successfully, but these errors were encountered: