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
{{ message }}
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.
What I would like to achieve is to allow Null values to be passed during instantiation with from_dict, but that they remain filtered out.
@dataclass
class WithOptional(JSONSchemaMixin):
my_field: Optional[str]
WithOptional.from_dict({ "my_field": None }) # Error, None is not of type str
@dataclass
class WithNullable(JSONSchemaMixin):
my_field: Nullable[str]
WithNullable.from_dict({ "my_field": None }) # Works
WithNullable.from_dict({ "my_field": None }).to_dict() # Includes { "my_field": None }, which is not what I want either
Is there a way to achieve this somehow ? I understand the need for Nullable, but I don't get why optional would fail to init with an explicit null value.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There should be an option to allow nullable fields. I propose the following api:
There are a couple of ways to support nullable fields in JSON schema, either:
or:
The former is not supported in Swagger / OpenAPI though. OpenAPI 3 also supports the following:
The text was updated successfully, but these errors were encountered: