-
Notifications
You must be signed in to change notification settings - Fork 641
Annotate nullable values as such in the OpenAPI schema #2316
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
Conversation
92c9b0a to
183c92e
Compare
Prior to this change, we allowed the return of `None` values from models, serializing them as `null`, but the schema didn't specify them as nullable, which would cause model output to fail validation. This only supports Pydantic V2, because, from what I can tell, Pydantic V1 doesn't give us any clues that a field allows `None` values.
183c92e to
5637b18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to merge (bar the input_seed.py file).
Regarding whether this is a breaking change. From what I understand, optional types will now include the nullable field on the OpenAPI schema for both inputs and outputs. In practice this allows a client to pass field: null in addition to omitting it from the request body, it also correctly types the output to indicate that output can be null, this has always been the case when a prediction is in a non-terminal state.
The only two failure modes I can think of are:
- Where someone is using the generated OpenAPI schema for something else. The new presence of the
nullablefield could change the behavior of whatever system is using the schema. - When the output schema is used to determine the type of the output. However this has always been a nullable field on the PredictionResponse so I would expect most consumers to handle this already despite the incorrect schema.
I think based on this we can class it as a bug fix without a major version bump.
Luckily we have another breaking change going in right now, the next bump will be to |
|
Going to merge this since we need to do a |
Prior to this change, we allowed the return of
Nonevalues from models, serializing them asnull, but the schema didn't specify them as nullable, which would cause model output to fail validation.This only supports Pydantic V2, because, from what I can tell, Pydantic V1 doesn't give us any clues that a field allows
Nonevalues.Note: this is probably a breaking change.