-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[Python-experimental] JSON schema 'null' type should be modeled as 'none_type' #6121
Conversation
@spacether , I'm not sure if I should handle the OAS |
I think that we need to add the type mapping but I have not used that before. For Python-experimental we should point it to our already defined none_type. |
ok, sure, let me try with typeMappings. |
samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py
Outdated
Show resolved
Hide resolved
samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml
Outdated
Show resolved
Hide resolved
...erator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java
Outdated
Show resolved
Hide resolved
...erator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache
Outdated
Show resolved
Hide resolved
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.
Please add a python test showing deserializing a None working correctly.
Added unit test |
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.
These python-experimental updates look good. Thank you for this PR.
@sebastien-rosset we need the CI tests to pass before we can merge this.
It might need parens around that statement because it is multiline, like:
Can you fix it? |
modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache
Show resolved
Hide resolved
@sebastien-rosset to fix this next CI-error you need to update this line:
or change the oneof_anyof_classes assignment in
|
I have some something like that here: https://github.com/OpenAPITools/openapi-generator/pull/5809/files#diff-cc72ac40056827e3a103f9b4f56059cfR70 I mentioned #5809 should be merged before this PR. |
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.
Thanks for this PR. The python-experimental updates look good to me.
Waiting for tests to pass.
It looks like recently something changed because the JSON schema
null
type is now causing problems. I'm not sure what specific commit caused this problem. ThegetTypeString
function in PythonClientExperimentalCodegen.java is incorrectly returningnull
when the input Schema is the Null type.For example, with the following schema, the generated python-experimental code has syntax errors.
Without this PR, the following import is incorrectly generated:
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.