-
-
Notifications
You must be signed in to change notification settings - Fork 228
Optional[datetime] field with value null/None gets isoparse'd #456
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
Comments
If the type of the generated model is See #385 for more info on the required vs nullable difference in spec. If your schema does have nullable: true in it then it sounds like a generation bug, as the type should be |
thanks for the quick response! yeah, I was indeed missing for example, in the generated
to
which now raises with a KeyError if timestamp is not found. and similarly, a timestamp argument now needs to be specified if instantiating via the constructor. |
Sounds like now it thinks the parameter is in the |
Just to be a little more clear, I believe you have a schema that looks something like this (depending on where it's defined). The property being "AModel": {
"required": [
"timestamp"
],
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "date-time",
"nullable": true
}
}
} |
thanks @dbanty, that was the problem. I'm using pydantic/fastapi, and adding |
I have a field in my generated model like this:
timestamp: Union[Unset, datetime.datetime] = UNSET
My API returns {"timestamp": null}, which then gets deserialized as None, and ends up in the else clause of this generated code:
.. when then ends up raising in dateutil's isoparser.py.
I'm using 0.10.1 and saw #381 and #420 - wondering if
datetime.datetime
wasn't fixed with that issue or if I'm doing something wrong?The text was updated successfully, but these errors were encountered: