-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[openapi spec 3.1.0][python-flask generator] Nullable properties not propagated to child models #19619
Comments
i tested with python-flask in the latest master and don't see i also tested with python client generator and couldn't repeat the issue, which means |
@wing328 yes you are right, we use a customized templates for our use case.
field_type.mustache: Do you recommend using the python generator instead of python flask for the models? |
using |
@wing328 thank you for pointing me towards the debugModels option it makes things clearer.
Is it possible that you might be looking at |
Btw, I found a workaround, there is a vendor extension that can be used to mark a property nullable. |
Description
Currently, we use openapi spec 3.0.3 with openapi-generator version 5.4.0 and we are planning to migrate to openapi spec 3.1.0 with the latest generator version.
While migrating to 3.1.0 I see that nullable is not supported anymore and we use the isNullable value to set our generated model instance variable to Optional as follows:
{{#isNullable}}Optional[{{/isNullable}}{{#isDateTime}}Union[datetime, DateTimeProxy]{{/isDateTime}}{{^isDateTime}}{{dataType}}{{/isDateTime}}{{#isNullable}}]{{/isNullable}}
I noticed that with the new version of the generator and openapi spec 3.1.0 when we set a property as "null" this constraint is not inherited by the child schema in the model generated. Here is a simple example:
Openapi spec 3.1.0:
Model generated:
base_user.py
user_response.py
Notice how the
id : Optional[str]
is not the same as parent in the child schema.This worked as expected with 3.0.3 and the new version of the generator as well. So makes me wonder if the 3.1.0 spec isNullable property is propagated to the child schema.
Please let me know if there is a way I can resolve this as we want to utilize the great features in 3.1.0 without breaking our client code.
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Command line used for generation
openapi-generator-cli generate --input-spec spec/bundle.yaml --config openapi-generator.yaml --output ../..
Note: the openapi-generator.yaml config file is straightforward and no options are enabled in it.
The text was updated successfully, but these errors were encountered: