Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !2049

[Python] add additionalProperties support, Option2

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/spacether/python_additionalprops_option2 into master Feb 04, 2019
  • Overview 0
  • Commits 25
  • Pipelines 0
  • Changes 297+

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, 3.4.x, 4.0.x. Default: 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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/spacether/python_additionalprops_option2