diff --git a/modules/openapi-generator/src/main/resources/python/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/model_utils.mustache index 4615a34ec335..4a99eab52a20 100644 --- a/modules/openapi-generator/src/main/resources/python/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_utils.mustache @@ -1450,7 +1450,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1512,10 +1515,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1570,7 +1579,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 763de9dc2e03..c78f42836063 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1666,6 +1666,10 @@ components: color: type: string default: red + tail: + type: boolean + default: true + readOnly: true AnimalFarm: type: array items: diff --git a/samples/client/petstore/python/petstore_api/model_utils.py b/samples/client/petstore/python/petstore_api/model_utils.py index aa747a3f9a8a..e7ef88f64f83 100644 --- a/samples/client/petstore/python/petstore_api/model_utils.py +++ b/samples/client/petstore/python/petstore_api/model_utils.py @@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py index aa747a3f9a8a..e7ef88f64f83 100644 --- a/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py +++ b/samples/client/petstore/python_disallowAdditionalPropertiesIfNotPresent/petstore_api/model_utils.py @@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py index 13277887d394..cef4b6c2373b 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py @@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py index fa10b2d24f93..2ad3e5bdeab6 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py @@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/samples/openapi3/client/petstore/python/docs/Animal.md b/samples/openapi3/client/petstore/python/docs/Animal.md index d36c66a5d882..2c3e499ed438 100644 --- a/samples/openapi3/client/petstore/python/docs/Animal.md +++ b/samples/openapi3/client/petstore/python/docs/Animal.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**tail** | **bool** | | [optional] [readonly] if omitted the server will use the default value of True **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[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/docs/Cat.md b/samples/openapi3/client/petstore/python/docs/Cat.md index 082715a28421..771510d15b81 100644 --- a/samples/openapi3/client/petstore/python/docs/Cat.md +++ b/samples/openapi3/client/petstore/python/docs/Cat.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **class_name** | **str** | | **declawed** | **bool** | | [optional] **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**tail** | **bool** | | [optional] [readonly] if omitted the server will use the default value of True **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[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/docs/ComposedOneOfNumberWithValidations.md b/samples/openapi3/client/petstore/python/docs/ComposedOneOfNumberWithValidations.md index 14c3f2ea4933..e71647c52247 100644 --- a/samples/openapi3/client/petstore/python/docs/ComposedOneOfNumberWithValidations.md +++ b/samples/openapi3/client/petstore/python/docs/ComposedOneOfNumberWithValidations.md @@ -6,6 +6,7 @@ this is a model that allows payloads of type object or number Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**tail** | **bool** | | [optional] [readonly] if omitted the server will use the default value of True **class_name** | **str** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] diff --git a/samples/openapi3/client/petstore/python/docs/Dog.md b/samples/openapi3/client/petstore/python/docs/Dog.md index 51b5b32bdacb..a3564c227f5a 100644 --- a/samples/openapi3/client/petstore/python/docs/Dog.md +++ b/samples/openapi3/client/petstore/python/docs/Dog.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes **class_name** | **str** | | **breed** | **str** | | [optional] **color** | **str** | | [optional] if omitted the server will use the default value of "red" +**tail** | **bool** | | [optional] [readonly] if omitted the server will use the default value of True **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[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/petstore_api/model/animal.py b/samples/openapi3/client/petstore/python/petstore_api/model/animal.py index fda6c283ebdc..cc070a6d8fe6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/animal.py @@ -91,6 +91,7 @@ def openapi_types(): return { 'class_name': (str,), # noqa: E501 'color': (str,), # noqa: E501 + 'tail': (bool,), # noqa: E501 } @cached_property @@ -107,9 +108,11 @@ def discriminator(): attribute_map = { 'class_name': 'className', # noqa: E501 'color': 'color', # noqa: E501 + 'tail': 'tail', # noqa: E501 } read_only_vars = { + 'tail', # noqa: E501 } _composed_schemas = {} @@ -154,6 +157,7 @@ def _from_openapi_data(cls, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -240,6 +244,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/cat.py b/samples/openapi3/client/petstore/python/petstore_api/model/cat.py index be46fe5abd8c..882376f11a6d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/cat.py @@ -92,6 +92,7 @@ def openapi_types(): 'class_name': (str,), # noqa: E501 'declawed': (bool,), # noqa: E501 'color': (str,), # noqa: E501 + 'tail': (bool,), # noqa: E501 } @cached_property @@ -106,9 +107,11 @@ def discriminator(): 'class_name': 'className', # noqa: E501 'declawed': 'declawed', # noqa: E501 'color': 'color', # noqa: E501 + 'tail': 'tail', # noqa: E501 } read_only_vars = { + 'tail', # noqa: E501 } @classmethod @@ -150,6 +153,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -252,6 +256,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py b/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py index 68847c276eee..062902afb308 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/composed_one_of_number_with_validations.py @@ -90,6 +90,7 @@ def openapi_types(): lazy_import() return { 'color': (str,), # noqa: E501 + 'tail': (bool,), # noqa: E501 'class_name': (str,), # noqa: E501 } @@ -100,10 +101,12 @@ def discriminator(): attribute_map = { 'color': 'color', # noqa: E501 + 'tail': 'tail', # noqa: E501 'class_name': 'className', # noqa: E501 } read_only_vars = { + 'tail', # noqa: E501 } @classmethod @@ -143,6 +146,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 class_name (str): [optional] # noqa: E501 """ @@ -244,6 +248,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 class_name (str): [optional] # noqa: E501 """ diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/dog.py b/samples/openapi3/client/petstore/python/petstore_api/model/dog.py index 4a20dafa46cc..671fbe3dae2c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model/dog.py @@ -92,6 +92,7 @@ def openapi_types(): 'class_name': (str,), # noqa: E501 'breed': (str,), # noqa: E501 'color': (str,), # noqa: E501 + 'tail': (bool,), # noqa: E501 } @cached_property @@ -106,9 +107,11 @@ def discriminator(): 'class_name': 'className', # noqa: E501 'breed': 'breed', # noqa: E501 'color': 'color', # noqa: E501 + 'tail': 'tail', # noqa: E501 } read_only_vars = { + 'tail', # noqa: E501 } @classmethod @@ -150,6 +153,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -252,6 +256,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 + tail (bool): [optional] if omitted the server will use the default value of True # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py index aa747a3f9a8a..e7ef88f64f83 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py @@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args): for allof_class in self._composed_schemas['allOf']: try: - allof_instance = allof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + allof_instance = allof_class._from_openapi_data(**model_args, **constant_args) + else: + allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( @@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): try: if not single_value_input: - oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs) + else: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) else: if issubclass(oneof_class, ModelSimple): - oneof_instance = oneof_class(model_arg, **constant_kwargs) + if constant_kwargs.get('_spec_property_naming'): + oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs) + else: + oneof_instance = oneof_class(model_arg, **constant_kwargs) elif oneof_class in PRIMITIVE_TYPES: oneof_instance = validate_and_convert_types( model_arg, @@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args): continue try: - anyof_instance = anyof_class(**model_args, **constant_args) + if constant_args.get('_spec_property_naming'): + anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args) + else: + anyof_instance = anyof_class(**model_args, **constant_args) anyof_instances.append(anyof_instance) except Exception: pass diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_issue10155.py b/samples/openapi3/client/petstore/python/tests_manual/test_issue10155.py new file mode 100755 index 000000000000..7c14b5f7e7a4 --- /dev/null +++ b/samples/openapi3/client/petstore/python/tests_manual/test_issue10155.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest +import json +from collections import namedtuple + +import petstore_api +from petstore_api.model.animal import Animal +from petstore_api.model.dog import Dog + + +class TestReadOnlyForComposedSchema(unittest.TestCase): + """TestReadOnlyForComposedSchema unit test""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testReadOnlyForComposedSchema(self): + """Test ReadOnlyForComposedSchema""" + MockResponse = namedtuple('MockResponse', 'data') + client = petstore_api.ApiClient() + """ deserialize dict(str, Enum_Test) """ + data = { + "Dog": { + "class_name": "Dog", + "breed": "BullDog", + "color": "Black", + "tail": True + } + } + response = MockResponse(data=json.dumps(data)) + deserialized = client.deserialize(response, ({str: (Dog,)},), True) + assert isinstance(deserialized, dict) + assert isinstance(deserialized['Dog'], Dog) + + +if __name__ == '__main__': + unittest.main()