-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Update parser to 2.0.29 #11388
Update parser to 2.0.29 #11388
Conversation
Updating the samples resulted in |
@spacether I wonder if you can take a look at the NPE above when you've time? Thanks. |
UPDATE: I've pushed e1bffbc to better handle the NPE |
samples/openapi3/client/petstore/python-experimental/petstore_api/model/nullable_shape.py
Outdated
Show resolved
Hide resolved
@@ -94,14 +95,14 @@ def _composed_schemas(cls): | |||
# code would be run when this module is imported, and these composed | |||
# classes don't exist yet because their module has not finished | |||
# loading | |||
oneOf_2 = NoneSchema | |||
oneOf_2 = AnyTypeSchema |
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.
@wing328
Something is not working right here. The schema is:
NullableShape:
description: The value may be a shape or the 'null' value.
The 'nullable' attribute was introduced in OAS schema >= 3.0
and has been deprecated in OAS schema >= 3.1.
For a nullable composed schema to work, one of its chosen oneOf schemas must be type null
oneOf:
- $ref: '#/components/schemas/Triangle'
- $ref: '#/components/schemas/Quadrilateral'
- type: null
discriminator:
propertyName: shapeType
nullable: true
So the 3rd oneOf schema should be NoneSchema NOT AnyTypeSchema.
AnyTypeSchema is {}
or true
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.
Yup, could be a regression. I tried updating the parser to 2.0.30 (released several hours ago) but no luck (no change in samples).
Can you please report the issue to swagger parser directly with the details when you've time?
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.
Yup, it could also be our code not seeing the null type right. If it is the parser I will report it.
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 did some investigating here:
- For yaml
type: null
the schema is defined as an type: null AnyType schema by swagger-parser - For yaml
type: "null"
the schema is correctly defined as type: "null" NoneSchema by swagger-parser
So I will:
- Update the spec to make the type be the quoted null value
- Remove the discriminator from that schema because per the openapi spec, when discriminator exists, then the discriminator key MUST exist in the payload. a null payload value cannot meet that constraint.
- Remove nullable: true because it had no impact on this schema and the type: "null" in the oneOf already allows null as does having an untyped composed schema.
Update parser to 2.0.29
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(5.3.0),6.0.x