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