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/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..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 @@ -8,30 +8,37 @@ ]) @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 + args[0] ({{{dataType}}}):{{#description}} {{description}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{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}} + 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 }} """ -{{^hasRequired}} if 'value' in kwargs: value = kwargs.pop('value') elif args: args = list(args) value = args.pop(0) +{{#defaultValue}} else: value = {{{defaultValue}}} -{{/hasRequired}} +{{/defaultValue}} +{{^defaultValue}} + 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__,), + ) +{{/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', ()) 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"); 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/client/petstore/python-experimental/petstore_api/model/animal_farm.py b/samples/client/petstore/python-experimental/petstore_api/model/animal_farm.py index dc35f9394e1c..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 @@ -99,13 +99,16 @@ 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 + args[0] ([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,6 +141,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -99,13 +99,16 @@ 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 + args[0] (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 Keyword Args: + 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. @@ -138,6 +141,14 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = "-efg" + _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/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..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 @@ -98,13 +98,16 @@ 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 + args[0] (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,6 +140,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -99,13 +99,16 @@ 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 + 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 will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,6 +141,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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) 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..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 @@ -99,13 +99,16 @@ 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 + args[0] ([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,6 +141,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -99,13 +99,16 @@ 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 + args[0] ([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,6 +141,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -99,13 +99,16 @@ 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 + args[0] (str): if omitted defaults to "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 Keyword Args: + 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. @@ -138,6 +141,14 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = "-efg" + _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.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/integer_enum.py index 67d924c427c0..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 @@ -99,13 +99,16 @@ 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 + 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 will be type checked and a TypeError will be raised if the wrong type is input. @@ -138,6 +141,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -100,8 +100,13 @@ 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: + 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. @@ -141,6 +146,7 @@ def __init__(self, *args, **kwargs): value = args.pop(0) else: value = 0 + _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..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 @@ -99,13 +99,16 @@ 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 + args[0] (int): if omitted defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 Keyword Args: + 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. @@ -138,6 +141,14 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = 0 + _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/number_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/number_with_validations.py index dac4ec635b81..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 @@ -98,13 +98,16 @@ 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 + args[0] (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,6 +140,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -105,15 +105,20 @@ 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 + 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 + 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,6 +151,18 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + 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) _path_to_item = kwargs.pop('_path_to_item', ()) 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..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 @@ -99,13 +99,16 @@ 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 + args[0] (str): if omitted defaults to "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 Keyword Args: + 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. @@ -138,6 +141,14 @@ def __init__(self, value, *args, **kwargs): _visited_composed_classes = (Animal,) """ + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) + else: + value = "placed" + _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/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