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
  • !3118

[python-experimental] automatically use values for enums of length1

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/spacether/issue_1812_use_enums_length1 into master Jun 07, 2019
  • Overview 0
  • Commits 13
  • Pipelines 0
  • Changes 72

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, ./bin/openapi3/{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\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.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

This PR updates the function signatures for models and endpoints FROM (req_arg1=None, req_arg2_with_default=None, optional_arg1=None): TO: (req_arg1, req_arg2_with_default=default_value, optional_arg1=None): So required arguments without defaults are now positional Required arguments with defaults are now named arguments which use the default value

  • If a variable has an enum of length one, we load that value into the default value

This is helpful because:

  • it clarifies from the function signature what is required versus optional
  • we are now automatically using enums of length one if the spec writer defines them

Note about invoking functions with positional args: In python2 and python3 if a function has a signature:

def func(arg1, arg2=None):
  pass
# one can invoke it with
func('arg1_val', arg2='blah')
# OR
func(arg1='arg1_val', arg2='blah')

So if people are invoking these functions with keyword arguments, they will continue working.

Positional vs Keyword Arguments:

If we do not like making these required arguments positional, and we want to keep them as keyword arguments, I can:

  • change the default values for them back to None
  • if not Nullable, throw an error if None is passed in on that variable

This PR also adds a windows tool at bin/windows/python-experimental-petstore.bat to generate the python-experimental sample client on windows machines. If merged, this PR will close out https://github.com/OpenAPITools/openapi-generator/issues/1812

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