Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,10 @@ components:
color:
type: string
default: red
tail:
type: boolean
default: true
readOnly: true
AnimalFarm:
type: array
items:
Expand Down
20 changes: 16 additions & 4 deletions samples/client/petstore/python/petstore_api/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions samples/openapi3/client/petstore/python/docs/Animal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions samples/openapi3/client/petstore/python/docs/Cat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions samples/openapi3/client/petstore/python/docs/Dog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def openapi_types():
return {
'class_name': (str,), # noqa: E501
'color': (str,), # noqa: E501
'tail': (bool,), # noqa: E501
}

@cached_property
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def openapi_types():
lazy_import()
return {
'color': (str,), # noqa: E501
'tail': (bool,), # noqa: E501
'class_name': (str,), # noqa: E501
}

Expand All @@ -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
Expand Down Expand Up @@ -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
"""

Expand Down Expand Up @@ -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
"""

Expand Down
Loading