Created by: spacether
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. -
Filed the PR against the correct branch: master
,. Default:3.4.x
,4.0.x
master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language. @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01)
Description of the PR
- Adds support for additionalProperties to the Python generator
- Fixes inheritance in python when AllOf is used
- Adds additionalProperties codegenParameter to the model that the mustache files have access to in case we want to use the schema for examples in the future
- Adds the ability to access and assign values to a model instance using brackets. model_instance['var_name'] = var_val
- Simplifies model instance variable storage by storing all values in a data dict. This will make it easier to send Nullable value=None items, because items in the data store are correct
- Switches parameter and discriminator typing to use actual python classes
- Adds type checking with TypeError/ValueError/KeyError exceptions which tell where in the data the problem is (data is in the exception string and exception.path_to_item)
- Model instances can be instantiated with type checking with the _check_type variable
- Endpoint hits can check type before sending out data with the _check_type variable
- Deserialization automatically checks type on all received data
Issues that will be closed if this is merged:
- Inheritance not working: https://github.com/OpenAPITools/openapi-generator/issues/623
- When model only has allOf, it is blank: https://github.com/OpenAPITools/openapi-generator/issues/453
- Fixes additionalproperties: https://github.com/OpenAPITools/openapi-generator/issues/2028
New Changes
- Model variable types, discriminators values, and response types are now all classes
- api_client call_api method keyword argument changed from response_type to response_types_mixed
- Mode instantiation:
- required arguments with no enums of length one are positional
- required arguments WITH enums of length one are set as keyword arguments with defaults = the enum value
- option arguments are keyword argument **kwargs
- This should be completely backwards compatible if people are using all keyword arguments which still works
Breaking Changes:
- Received date and date-time data that is not parsable will now raise an ApiValueError which can be captured with ValueError, Exception, ApiValueError, or OpenApiException. Date/date-time variable will not fall back to string values. Instead one must set the type of that variable in the spec equal to {} which allows that variable to hold any of the openapi types. An example of this can be seen at: samples/client/petstore/python/tests/test_deserialization.py::test_deserialize_str_to_date_failure
Note:
This is an alternative solution to this PR: https://github.com/OpenAPITools/openapi-generator/pull/2029