From c0579635f1061c35a63f916886e202bf65339e4c Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Tue, 15 Sep 2020 15:28:43 +0200 Subject: [PATCH 1/5] [Python-experimental] Don't mandate passing in required value as argument --- .../method_init_simple.mustache | 27 +++++++++++++------ .../petstore_api/model/animal_farm.py | 22 +++++++++++++-- .../petstore_api/model/enum_class.py | 25 +++++++++++++++-- .../model/number_with_validations.py | 22 +++++++++++++-- .../petstore_api/model/string_enum.py | 22 +++++++++++++-- .../petstore_api/model/animal_farm.py | 22 +++++++++++++-- .../petstore_api/model/array_of_enums.py | 22 +++++++++++++-- .../petstore_api/model/enum_class.py | 25 +++++++++++++++-- .../petstore_api/model/integer_enum.py | 22 +++++++++++++-- .../model/integer_enum_one_value.py | 10 +++++++ .../model/integer_enum_with_default_value.py | 25 +++++++++++++++-- .../model/number_with_validations.py | 22 +++++++++++++-- .../petstore_api/model/string_enum.py | 24 +++++++++++++++-- .../model/string_enum_with_default_value.py | 25 +++++++++++++++-- 14 files changed, 283 insertions(+), 32 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache index 9d59b7ba0914..29936bc70ac5 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache @@ -8,36 +8,47 @@ ]) @convert_js_args_to_python_args - def __init__(self{{#hasRequired}}, value{{/hasRequired}}, *args, **kwargs): + def __init__(self, *args, **kwargs): """{{classname}} - a model defined in OpenAPI -{{#hasRequired}} + Note that value can be passed either in args or in kwargs, but not in both. + Args: value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 - -{{/hasRequired}} Keyword Args: -{{^hasRequired}} value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 -{{/hasRequired}} {{> python-experimental/model_templates/docstring_init_required_kwargs }} """ -{{^hasRequired}} + value = None + have_value = False if 'value' in kwargs: value = kwargs.pop('value') + have_value = True elif args: args = list(args) value = args.pop(0) + have_value = True +{{#defaultValue}} else: value = {{{defaultValue}}} -{{/hasRequired}} + have_value = True +{{/defaultValue}} + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) +{{#hasRequired}} + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) +{{/hasRequired}} if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py index dc35f9394e1c..830470ec3f70 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """AnimalFarm - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value ([Animal]): # noqa: E501 - Keyword Args: + value ([Animal]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py index 2052f27748f0..301caeb6ac00 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """EnumClass - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 - Keyword Args: + value (str): defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,31 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + else: + value = "-efg" + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index 00656ce8bcf7..ffddb78df256 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -98,13 +98,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """NumberWithValidations - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (float): # noqa: E501 - Keyword Args: + value (float): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -137,12 +139,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py index 1fd2b6746989..51a5d6119a65 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """StringEnum - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 - Keyword Args: + value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py index dc35f9394e1c..830470ec3f70 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """AnimalFarm - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value ([Animal]): # noqa: E501 - Keyword Args: + value ([Animal]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py index 7de4cae7f1eb..2d5c5b12bb9b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """ArrayOfEnums - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value ([StringEnum]): # noqa: E501 - Keyword Args: + value ([StringEnum]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py index 2052f27748f0..301caeb6ac00 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """EnumClass - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 - Keyword Args: + value (str): defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,31 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + else: + value = "-efg" + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py index 67d924c427c0..10418d2bfb49 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """IntegerEnum - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (int):, must be one of [0, 1, 2, ] # noqa: E501 - Keyword Args: + value (int):, must be one of [0, 1, 2, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py index 2ce011ae21dd..e68276c1e816 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py @@ -100,6 +100,10 @@ def discriminator(): def __init__(self, *args, **kwargs): """IntegerEnumOneValue - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + value (int): if omitted the server will use the default value of 0, must be one of [0, ] # noqa: E501 Keyword Args: value (int): defaults to 0, must be one of [0, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -134,13 +138,19 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False if 'value' in kwargs: value = kwargs.pop('value') + have_value = True elif args: args = list(args) value = args.pop(0) + have_value = True else: value = 0 + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py index 04884c5dfdc3..34f5d64db61f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """IntegerEnumWithDefaultValue - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (int): if omitted the server will use the default value of 0, must be one of [0, 1, 2, ] # noqa: E501 - Keyword Args: + value (int): defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,31 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + else: + value = 0 + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index dac4ec635b81..524ed2ff8390 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -98,13 +98,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """NumberWithValidations - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (float): # noqa: E501 - Keyword Args: + value (float): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -137,12 +139,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index 9c7ffa0854c8..a91a72ee1f9c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -105,15 +105,19 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """StringEnum - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple lines''', '''double quote with newline''', ] # noqa: E501 - Keyword Args: + value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple +lines''', '''double quote + with newline''', ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -146,12 +150,28 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py index 7431e0d1d920..44be79bcedd1 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py @@ -99,13 +99,15 @@ def discriminator(): ]) @convert_js_args_to_python_args - def __init__(self, value, *args, **kwargs): + def __init__(self, *args, **kwargs): """StringEnumWithDefaultValue - a model defined in OpenAPI + Note that value can be passed either in args or in kwargs, but not in both. + Args: value (str): if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 - Keyword Args: + value (str): defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,12 +140,31 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + value = None + have_value = False + if 'value' in kwargs: + value = kwargs.pop('value') + have_value = True + elif args: + args = list(args) + value = args.pop(0) + have_value = True + else: + value = "placed" + have_value = True + _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if not have_value: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( From 5355f802afb80dae3033d2338dd43c89dc6a4957 Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Tue, 22 Sep 2020 10:24:57 +0200 Subject: [PATCH 2/5] Remove usage of have_value --- .../method_init_simple.mustache | 22 +++++++++---------- .../petstore_api/model/animal_farm.py | 15 +++++-------- .../petstore_api/model/enum_class.py | 10 --------- .../model/number_with_validations.py | 15 +++++-------- .../petstore_api/model/string_enum.py | 15 +++++-------- .../petstore_api/model/animal_farm.py | 15 +++++-------- .../petstore_api/model/array_of_enums.py | 15 +++++-------- .../petstore_api/model/enum_class.py | 10 --------- .../petstore_api/model/integer_enum.py | 15 +++++-------- .../model/integer_enum_one_value.py | 4 ---- .../model/integer_enum_with_default_value.py | 10 --------- .../model/number_with_validations.py | 15 +++++-------- .../petstore_api/model/string_enum.py | 15 +++++-------- .../model/string_enum_with_default_value.py | 10 --------- 14 files changed, 58 insertions(+), 128 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache index 29936bc70ac5..bde63c4bedf7 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache @@ -21,34 +21,32 @@ """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True {{#defaultValue}} else: value = {{{defaultValue}}} - have_value = True {{/defaultValue}} - - _check_type = kwargs.pop('_check_type', True) - _spec_property_naming = kwargs.pop('_spec_property_naming', False) - _path_to_item = kwargs.pop('_path_to_item', ()) - _configuration = kwargs.pop('_configuration', None) - _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - +{{^defaultValue}} {{#hasRequired}} - if not have_value: + else: raise ApiTypeError( "value is required, but not passed in args or kwargs and doesn't have default", path_to_item=_path_to_item, valid_classes=(self.__class__,), ) {{/hasRequired}} +{{/defaultValue}} + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py index 830470ec3f70..d0b457f36f99 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -141,14 +141,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -156,12 +159,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py index 301caeb6ac00..83002d5baa57 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -141,17 +141,13 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True else: value = "-efg" - have_value = True _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -159,12 +155,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index ffddb78df256..247bcc96313d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -140,14 +140,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -155,12 +158,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py index 51a5d6119a65..66ea7ecd1047 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -141,14 +141,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -156,12 +159,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py index 830470ec3f70..d0b457f36f99 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -141,14 +141,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -156,12 +159,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py index 2d5c5b12bb9b..17f4d225cddd 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py @@ -141,14 +141,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -156,12 +159,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py index 301caeb6ac00..83002d5baa57 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -141,17 +141,13 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True else: value = "-efg" - have_value = True _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -159,12 +155,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py index 10418d2bfb49..dac412ea6d10 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py @@ -141,14 +141,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -156,12 +159,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py index e68276c1e816..b844ae76c3ef 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py @@ -139,17 +139,13 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True else: value = 0 - have_value = True _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py index 34f5d64db61f..32ccc68f0d5a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py @@ -141,17 +141,13 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True else: value = 0 - have_value = True _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -159,12 +155,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index 524ed2ff8390..b9fb235d2000 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -140,14 +140,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -155,12 +158,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index a91a72ee1f9c..e7807762120e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -151,14 +151,17 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True + else: + raise ApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -166,12 +169,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py index 44be79bcedd1..3b27e8cf4212 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py @@ -141,17 +141,13 @@ def __init__(self, *args, **kwargs): """ value = None - have_value = False if 'value' in kwargs: value = kwargs.pop('value') - have_value = True elif args: args = list(args) value = args.pop(0) - have_value = True else: value = "placed" - have_value = True _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) @@ -159,12 +155,6 @@ def __init__(self, *args, **kwargs): _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) - if not have_value: - raise ApiTypeError( - "value is required, but not passed in args or kwargs and doesn't have default", - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( From 0e3d3a3aa4df64bec4c103797ed01bd55caf3a7e Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Wed, 23 Sep 2020 11:27:36 +0200 Subject: [PATCH 3/5] Address additional review comments --- .../languages/PythonClientExperimentalCodegen.java | 8 ++++---- .../client/petstore/python-experimental/docs/EnumClass.md | 2 +- .../client/petstore/python-experimental/docs/EnumClass.md | 2 +- .../docs/IntegerEnumWithDefaultValue.md | 2 +- .../docs/StringEnumWithDefaultValue.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index f156a44e6e99..9c4bd3bbb92d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -723,11 +723,11 @@ public CodegenModel fromModel(String name, Schema sc) { // 1. no default exists // schema does not contain default // cm.defaultValue unset, cm.hasRequired = true - // 2. server has a default + // 2. spec has a default // schema contains default - // cm.defaultValue set, cm.hasRequired = true + // cm.defaultValue set, cm.hasRequired = false // different value here to differentiate between use case 3 below - // This defaultValue is used in the client docs only and is not sent to the server + // This defaultValue is used when a consumer (client or server) lacks the input argument, defaultValue will be used // 3. only one value is allowed in an enum // schema does not contain default // cm.defaultValue set, cm.hasRequired = false @@ -738,7 +738,7 @@ public CodegenModel fromModel(String name, Schema sc) { cm.hasRequired = true; } else if (sc.getDefault() != null) { cm.defaultValue = defaultValue; - cm.hasRequired = true; + cm.hasRequired = false; } else if (defaultValue != null && cm.defaultValue == null) { cm.defaultValue = defaultValue; cm.hasRequired = false; diff --git a/samples/client/petstore/python-experimental/docs/EnumClass.md b/samples/client/petstore/python-experimental/docs/EnumClass.md index 6c5c0619a1b0..6dda7fd8a77f 100644 --- a/samples/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/client/petstore/python-experimental/docs/EnumClass.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] +**value** | **str** | | defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md b/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md index 6c5c0619a1b0..6dda7fd8a77f 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] +**value** | **str** | | defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/IntegerEnumWithDefaultValue.md b/samples/openapi3/client/petstore/python-experimental/docs/IntegerEnumWithDefaultValue.md index b2ae7cef0d36..9988294c0373 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/IntegerEnumWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/IntegerEnumWithDefaultValue.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **int** | | if omitted the server will use the default value of 0, must be one of [0, 1, 2, ] +**value** | **int** | | defaults to 0, must be one of [0, 1, 2, ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md b/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md index 74cc456c84f9..13cc075ab34e 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] +**value** | **str** | | defaults to "placed", must be one of ["placed", "approved", "delivered", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) From 5aed86ea03f11666a72f050abd3ffb25fb353c2b Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Wed, 23 Sep 2020 11:36:34 +0200 Subject: [PATCH 4/5] Fix tests according to the code change --- .../codegen/python/PythonClientExperimentalTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java index 4807ea2f3ceb..093598d02ce4 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java @@ -375,7 +375,7 @@ public void defaultSettingInPrimitiveModelWithValidations() { final CodegenModel hasDefaultModel = codegen.fromModel("hasDefaultModel", hasDefault); Assert.assertEquals(hasDefaultModel.defaultValue, "15.0"); - Assert.assertEquals(hasDefaultModel.hasRequired, true); + Assert.assertEquals(hasDefaultModel.hasRequired, false); final CodegenModel noDefaultEumLengthOneModel = codegen.fromModel("noDefaultEumLengthOneModel", noDefaultEumLengthOne); Assert.assertEquals(noDefaultEumLengthOneModel.defaultValue, "15.0"); From 38f258ac9eadee8e2684ea2dbc405bfc3c6edf22 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 29 Sep 2020 09:23:44 -0700 Subject: [PATCH 5/5] Does not set None as value initial value, removes hasRequired tag usage, updates docstring --- .../model_templates/method_init_simple.mustache | 8 +++----- .../petstore_api/model/animal_farm.py | 4 ++-- .../petstore_api/model/enum_class.py | 6 +++--- .../petstore_api/model/number_with_validations.py | 4 ++-- .../petstore_api/model/string_enum.py | 4 ++-- .../petstore_api/model/animal_farm.py | 4 ++-- .../petstore_api/model/array_of_enums.py | 4 ++-- .../petstore_api/model/enum_class.py | 6 +++--- .../petstore_api/model/integer_enum.py | 4 ++-- .../petstore_api/model/integer_enum_one_value.py | 6 +++--- .../model/integer_enum_with_default_value.py | 6 +++--- .../petstore_api/model/number_with_validations.py | 4 ++-- .../petstore_api/model/string_enum.py | 4 ++-- .../model/string_enum_with_default_value.py | 6 +++--- .../python-experimental/testfiles/rsa.pem | 15 +++++++++++++++ 15 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache index bde63c4bedf7..b71b80667c06 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_simple.mustache @@ -14,13 +14,13 @@ Note that value can be passed either in args or in kwargs, but not in both. Args: - value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + args[0] ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + Keyword Args: - value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + value ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 {{> python-experimental/model_templates/docstring_init_required_kwargs }} """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: @@ -31,14 +31,12 @@ value = {{{defaultValue}}} {{/defaultValue}} {{^defaultValue}} -{{#hasRequired}} else: raise ApiTypeError( "value is required, but not passed in args or kwargs and doesn't have default", path_to_item=_path_to_item, valid_classes=(self.__class__,), ) -{{/hasRequired}} {{/defaultValue}} _check_type = kwargs.pop('_check_type', True) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py index d0b457f36f99..bf7bbf04c38f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value ([Animal]): # noqa: E501 + args[0] ([Animal]): # noqa: E501 + Keyword Args: value ([Animal]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py index 83002d5baa57..208019cfe111 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -105,9 +105,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + args[0] (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + Keyword Args: - value (str): defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + value (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index 247bcc96313d..51e7dece4b27 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -104,7 +104,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (float): # noqa: E501 + args[0] (float): # noqa: E501 + Keyword Args: value (float): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -139,7 +140,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py index 66ea7ecd1047..8d8be9601454 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 + args[0] (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 + Keyword Args: value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py index d0b457f36f99..bf7bbf04c38f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal_farm.py @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value ([Animal]): # noqa: E501 + args[0] ([Animal]): # noqa: E501 + Keyword Args: value ([Animal]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py index 17f4d225cddd..afcea8b9303d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/array_of_enums.py @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value ([StringEnum]): # noqa: E501 + args[0] ([StringEnum]): # noqa: E501 + Keyword Args: value ([StringEnum]): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py index 83002d5baa57..208019cfe111 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -105,9 +105,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + args[0] (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + Keyword Args: - value (str): defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + value (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py index dac412ea6d10..43abd8e0286d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py @@ -105,7 +105,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (int):, must be one of [0, 1, 2, ] # noqa: E501 + args[0] (int):, must be one of [0, 1, 2, ] # noqa: E501 + Keyword Args: value (int):, must be one of [0, 1, 2, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py index b844ae76c3ef..9df9dd15a5f9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_one_value.py @@ -103,9 +103,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (int): if omitted the server will use the default value of 0, must be one of [0, ] # noqa: E501 + args[0] (int): if omitted defaults to 0, must be one of [0, ] # noqa: E501 + Keyword Args: - value (int): defaults to 0, must be one of [0, ] # noqa: E501 + value (int): if omitted defaults to 0, must be one of [0, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,7 +139,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py index 32ccc68f0d5a..3c325e399706 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum_with_default_value.py @@ -105,9 +105,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (int): if omitted the server will use the default value of 0, must be one of [0, 1, 2, ] # noqa: E501 + args[0] (int): if omitted defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 + Keyword Args: - value (int): defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 + value (int): if omitted defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index b9fb235d2000..feef9f4317a2 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py @@ -104,7 +104,8 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (float): # noqa: E501 + args[0] (float): # noqa: E501 + Keyword Args: value (float): # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -139,7 +140,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index e7807762120e..2dee202bd3fc 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -111,9 +111,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple + args[0] (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple lines''', '''double quote with newline''', ] # noqa: E501 + Keyword Args: value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple lines''', '''double quote @@ -150,7 +151,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py index 3b27e8cf4212..f25d079379d9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py @@ -105,9 +105,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - value (str): if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 + args[0] (str): if omitted defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 + Keyword Args: - value (str): defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 + value (str): if omitted defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -140,7 +141,6 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ - value = None if 'value' in kwargs: value = kwargs.pop('value') elif args: diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem new file mode 100644 index 000000000000..ddc2c9767c4e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF +NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F +UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB +AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA +QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK +kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg +f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u +412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc +mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 +kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA +gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW +G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI +7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== +-----END RSA PRIVATE KEY----- \ No newline at end of file