diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index e43a08e812d6..3d1758ac7ec6 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -220,7 +220,7 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: @@ -336,10 +336,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append( - [{{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_item.to_dict(){{/compatibleWithPythonLegacy}} for _inner_item in _item_{{{name}}} if _inner_item is not None] - ) + _items.append( + [{{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_item.to_dict(){{/compatibleWithPythonLegacy}} if _inner_item is not None else None for _inner_item in _item_{{{name}}}] if _item_{{{name}}} is not None else None + ) _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.items.isPrimitiveType}} {{/items.isArray}} @@ -349,10 +348,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append( - {_inner_key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_value.to_dict(){{/compatibleWithPythonLegacy}} for _inner_key, _inner_value in _item_{{{name}}}.items()} - ) + _items.append( + {_inner_key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_inner_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_inner_value.to_dict(){{/compatibleWithPythonLegacy}} if _inner_value is not None else None for _inner_key, _inner_value in _item_{{{name}}}.items()} if _item_{{{name}}} is not None else None + ) _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.items.isPrimitiveType}} {{/items.isMap}} @@ -364,8 +362,7 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append({{#compatibleWithPythonLegacy}}_to_openapi_value(_item_{{{name}}}){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item_{{{name}}}.to_dict(){{/compatibleWithPythonLegacy}}) + _items.append({{#compatibleWithPythonLegacy}}_to_openapi_value(_item_{{{name}}}){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item_{{{name}}}.to_dict(){{/compatibleWithPythonLegacy}} if _item_{{{name}}} is not None else None) _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} @@ -379,10 +376,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _field_dict_of_array = {} if self.{{{name}}}: for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}] is not None: - _field_dict_of_array[_key_{{{name}}}] = [ - {{#compatibleWithPythonLegacy}}_to_openapi_value(_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item.to_dict(){{/compatibleWithPythonLegacy}} for _item in self.{{{name}}}[_key_{{{name}}}] - ] + _field_dict_of_array[_key_{{{name}}}] = [ + {{#compatibleWithPythonLegacy}}_to_openapi_value(_item){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_item.to_dict(){{/compatibleWithPythonLegacy}} if _item is not None else None for _item in self.{{{name}}}[_key_{{{name}}}] + ] if self.{{{name}}}[_key_{{{name}}}] is not None else None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_array {{/items.items.isPrimitiveType}} {{/items.isArray}} @@ -392,10 +388,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _field_dict_of_dict = {} if self.{{{name}}}: for _key_{{{name}}}, _value_{{{name}}} in self.{{{name}}}.items(): - if _value_{{{name}}} is not None: - _field_dict_of_dict[_key_{{{name}}}] = { - _key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_value.to_dict(){{/compatibleWithPythonLegacy}} for _key, _value in _value_{{{name}}}.items() - } + _field_dict_of_dict[_key_{{{name}}}] = { + _key: {{#compatibleWithPythonLegacy}}_to_openapi_value(_value){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}_value.to_dict(){{/compatibleWithPythonLegacy}} if _value is not None else None for _key, _value in _value_{{{name}}}.items() + } if _value_{{{name}}} is not None else None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_dict {{/items.items.isPrimitiveType}} {{/items.isMap}} @@ -407,8 +402,7 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _field_dict = {} if self.{{{name}}}: for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}]: - _field_dict[_key_{{{name}}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}[_key_{{{name}}}]){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}[_key_{{{name}}}].to_dict(){{/compatibleWithPythonLegacy}} + _field_dict[_key_{{{name}}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}[_key_{{{name}}}]){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}[_key_{{{name}}}].to_dict(){{/compatibleWithPythonLegacy}} if self.{{{name}}}[_key_{{{name}}}] is not None else None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} @@ -512,7 +506,7 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb {{/items.items.isPrimitiveType}} {{^items.items.isPrimitiveType}} {{{vendorExtensions.x-py-wire-name-literal}}}: [ - [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] + [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj[{{{vendorExtensions.x-py-wire-name-literal}}}] ] if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} @@ -523,7 +517,7 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb {{/items.items.isPrimitiveType}} {{^items.items.isPrimitiveType}} {{{vendorExtensions.x-py-wire-name-literal}}}: [ - {_inner_key: {{{items.items.dataType}}}.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: {{{items.items.dataType}}}.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj[{{{vendorExtensions.x-py-wire-name-literal}}}] ] if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} @@ -594,12 +588,12 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb {{{vendorExtensions.x-py-wire-name-literal}}}: {{{dataType}}}.from_dict(obj[{{{vendorExtensions.x-py-wire-name-literal}}}]) if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else None{{^-last}},{{/-last}} {{/isEnumOrRef}} {{#isEnumOrRef}} - {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{#defaultValue}} if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else {{{defaultValue}}}{{/defaultValue}}{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{#defaultValue}} if {{#isNullable}}{{{vendorExtensions.x-py-wire-name-literal}}} in obj{{/isNullable}}{{^isNullable}}obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None{{/isNullable}} else {{{defaultValue}}}{{/defaultValue}}{{^-last}},{{/-last}} {{/isEnumOrRef}} {{/isPrimitiveType}} {{#isPrimitiveType}} {{#defaultValue}} - {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) if obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None else {{{defaultValue}}}{{^-last}},{{/-last}} + {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) if {{#isNullable}}{{{vendorExtensions.x-py-wire-name-literal}}} in obj{{/isNullable}}{{^isNullable}}obj.get({{{vendorExtensions.x-py-wire-name-literal}}}) is not None{{/isNullable}} else {{{defaultValue}}}{{^-last}},{{/-last}} {{/defaultValue}} {{^defaultValue}} {{{vendorExtensions.x-py-wire-name-literal}}}: obj.get({{{vendorExtensions.x-py-wire-name-literal}}}){{^-last}},{{/-last}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index 9a9f1b9d93dc..123de7d19268 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -94,8 +94,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items return _dict diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index de25543601f6..a9df04fb4fc2 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -94,8 +94,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items return _dict diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/models/legacy_model.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/models/legacy_model.py index 8eba1871bb40..d64b16847e2c 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/models/legacy_model.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/models/legacy_model.py @@ -328,51 +328,45 @@ def __openapi_generator_modern_projection(self) -> Dict[str, Any]: _items = [] if self.nested_list: for _item_nested_list in self.nested_list: - if _item_nested_list: - _items.append(_to_openapi_value(_item_nested_list)) + _items.append(_to_openapi_value(_item_nested_list) if _item_nested_list is not None else None) _dict['nestedList'] = _items # override the default output from pydantic by calling `to_dict()` of each value in nested_map (dict) _field_dict = {} if self.nested_map: for _key_nested_map in self.nested_map: - if self.nested_map[_key_nested_map]: - _field_dict[_key_nested_map] = _to_openapi_value(self.nested_map[_key_nested_map]) + _field_dict[_key_nested_map] = _to_openapi_value(self.nested_map[_key_nested_map]) if self.nested_map[_key_nested_map] is not None else None _dict['nestedMap'] = _field_dict # override the default output from pydantic by calling `to_dict()` of each item in nested_lists (list of list) _items = [] if self.nested_lists: for _item_nested_lists in self.nested_lists: - if _item_nested_lists: - _items.append( - [_to_openapi_value(_inner_item) for _inner_item in _item_nested_lists if _inner_item is not None] - ) + _items.append( + [_to_openapi_value(_inner_item) if _inner_item is not None else None for _inner_item in _item_nested_lists] if _item_nested_lists is not None else None + ) _dict['nestedLists'] = _items # override the default output from pydantic by calling `to_dict()` of each item in nested_maps (list of dict) _items = [] if self.nested_maps: for _item_nested_maps in self.nested_maps: - if _item_nested_maps: - _items.append( - {_inner_key: _to_openapi_value(_inner_value) for _inner_key, _inner_value in _item_nested_maps.items()} - ) + _items.append( + {_inner_key: _to_openapi_value(_inner_value) if _inner_value is not None else None for _inner_key, _inner_value in _item_nested_maps.items()} if _item_nested_maps is not None else None + ) _dict['nestedMaps'] = _items # override the default output from pydantic by calling `to_dict()` of each value in map_of_lists (dict of array) _field_dict_of_array = {} if self.map_of_lists: for _key_map_of_lists in self.map_of_lists: - if self.map_of_lists[_key_map_of_lists] is not None: - _field_dict_of_array[_key_map_of_lists] = [ - _to_openapi_value(_item) for _item in self.map_of_lists[_key_map_of_lists] - ] + _field_dict_of_array[_key_map_of_lists] = [ + _to_openapi_value(_item) if _item is not None else None for _item in self.map_of_lists[_key_map_of_lists] + ] if self.map_of_lists[_key_map_of_lists] is not None else None _dict['mapOfLists'] = _field_dict_of_array # override the default output from pydantic by calling `to_dict()` of each value in map_of_maps (dict of dict) _field_dict_of_dict = {} if self.map_of_maps: for _key_map_of_maps, _value_map_of_maps in self.map_of_maps.items(): - if _value_map_of_maps is not None: - _field_dict_of_dict[_key_map_of_maps] = { - _key: _to_openapi_value(_value) for _key, _value in _value_map_of_maps.items() - } + _field_dict_of_dict[_key_map_of_maps] = { + _key: _to_openapi_value(_value) if _value is not None else None for _key, _value in _value_map_of_maps.items() + } if _value_map_of_maps is not None else None _dict['mapOfMaps'] = _field_dict_of_dict # set to None if nullable_value (nullable) is None # and model_fields_set contains the field @@ -424,11 +418,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: if obj.get("nestedMap") is not None else None, "nestedLists": [ - [NestedModel.from_dict(_inner_item) for _inner_item in _item] + [NestedModel.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["nestedLists"] ] if obj.get("nestedLists") is not None else None, "nestedMaps": [ - {_inner_key: NestedModel.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: NestedModel.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["nestedMaps"] ] if obj.get("nestedMaps") is not None else None, "mapOfLists": { diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index e4e4dbe21dea..c305a68c725f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -76,10 +76,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_dict = {} if self.map_of_map_non_primitive_property: for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): - if _value_map_of_map_non_primitive_property is not None: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { - _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() - } + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() + } if _value_map_of_map_non_primitive_property is not None else None _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index d2b83fbdb9d7..7337a96aa42c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -56,7 +56,7 @@ class Animal(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index ffdae49f239b..896229b2570a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] if _item_another_property is not None else None + ) _dict['another_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] + [Tag.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py index 3db556b3eb8a..8e03d5766e33 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_of_map_property: for _item_array_of_map_property in self.array_of_map_property: - if _item_array_of_map_property: - _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} - ) + _items.append( + {_inner_key: _inner_value.to_dict() if _inner_value is not None else None for _inner_key, _inner_value in _item_array_of_map_property.items()} if _item_array_of_map_property is not None else None + ) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "array_of_map_property": [ - {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["array_of_map_property"] ] if obj.get("array_of_map_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index b47021e9adb0..bb80aa6ab77d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -78,10 +78,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_array_of_model: for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] if _item_array_array_of_model is not None else None + ) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +98,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "array_of_nullable_float": obj.get("array_of_nullable_float"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index 3b8f10a664b0..955dd21246d4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -55,7 +55,7 @@ class BaseDiscriminator(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index a7ea1daf778d..69d6cfd2bdf4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.second_circular_all_of_ref: for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) + _items.append(_item_second_circular_all_of_ref.to_dict() if _item_second_circular_all_of_ref is not None else None) _dict['secondCircularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index e2af9fc33051..29cfc5e5f56c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -56,7 +56,7 @@ class Creature(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index ef7f96a4b4c3..275312d713ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -54,7 +54,7 @@ class DiscriminatorAllOfSuper(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index 4c04c79dad7d..5e8ca6861d83 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index 2dd24cc67053..e03dd4fc3839 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 8f8d882c67b3..e22e38fe0b59 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ + _item.to_dict() if _item is not None else None for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] + ] if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None else None _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index f1ef7f55ead3..20091d09ce86 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() + _field_dict[_key_map] = self.map[_key_map].to_dict() if self.map[_key_map] is not None else None _dict['map'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index 0a3e337a950f..00d62ef2df3e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -76,15 +76,13 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # override the default output from pydantic by calling `to_dict()` of each item in files (list) _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index b8a5de498efe..6d952bc4d557 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 5193e6750c1f..073836419245 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index 95eb764baadb..ad545ecdd848 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -94,8 +94,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index d48ade5d9984..e34512b98d55 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index b56e8782933e..d8112af7e452 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.circular_all_of_ref: for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) + _items.append(_item_circular_all_of_ref.to_dict() if _item_circular_all_of_ref is not None else None) _dict['circularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 4c79fe8bc7e5..100b8df77e60 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.dict_property: for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] + _field_dict_of_array[_key_dict_property] = [ + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] + ] if self.dict_property[_key_dict_property] is not None else None _dict['dictProperty'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/additional_properties_class.py index e4e4dbe21dea..c305a68c725f 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/additional_properties_class.py @@ -76,10 +76,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_dict = {} if self.map_of_map_non_primitive_property: for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): - if _value_map_of_map_non_primitive_property is not None: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { - _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() - } + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() + } if _value_map_of_map_non_primitive_property is not None else None _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/animal.py index d2b83fbdb9d7..7337a96aa42c 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/animal.py @@ -56,7 +56,7 @@ class Animal(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_array_of_model.py index ffdae49f239b..896229b2570a 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] if _item_another_property is not None else None + ) _dict['another_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] + [Tag.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_map_model.py index 3db556b3eb8a..8e03d5766e33 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_map_model.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_map_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_of_map_property: for _item_array_of_map_property in self.array_of_map_property: - if _item_array_of_map_property: - _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} - ) + _items.append( + {_inner_key: _inner_value.to_dict() if _inner_value is not None else None for _inner_key, _inner_value in _item_array_of_map_property.items()} if _item_array_of_map_property is not None else None + ) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "array_of_map_property": [ - {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["array_of_map_property"] ] if obj.get("array_of_map_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_test.py index b47021e9adb0..bb80aa6ab77d 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_test.py @@ -78,10 +78,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_array_of_model: for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] if _item_array_array_of_model is not None else None + ) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +98,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "array_of_nullable_float": obj.get("array_of_nullable_float"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/base_discriminator.py index 3b8f10a664b0..955dd21246d4 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/base_discriminator.py @@ -55,7 +55,7 @@ class BaseDiscriminator(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/circular_all_of_ref.py index a7ea1daf778d..69d6cfd2bdf4 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.second_circular_all_of_ref: for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) + _items.append(_item_second_circular_all_of_ref.to_dict() if _item_second_circular_all_of_ref is not None else None) _dict['secondCircularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/creature.py index e2af9fc33051..29cfc5e5f56c 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/creature.py @@ -56,7 +56,7 @@ class Creature(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/discriminator_all_of_super.py index ef7f96a4b4c3..275312d713ad 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/discriminator_all_of_super.py @@ -54,7 +54,7 @@ class DiscriminatorAllOfSuper(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/file_schema_test_class.py index 4c04c79dad7d..5e8ca6861d83 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/file_schema_test_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/input_all_of.py index 2dd24cc67053..e03dd4fc3839 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/input_all_of.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/map_of_array_of_model.py index 8f8d882c67b3..e22e38fe0b59 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/map_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ + _item.to_dict() if _item is not None else None for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] + ] if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None else None _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/mixed_properties_and_additional_properties_class.py index f1ef7f55ead3..20091d09ce86 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() + _field_dict[_key_map] = self.map[_key_map].to_dict() if self.map[_key_map] is not None else None _dict['map'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/multi_arrays.py index 0a3e337a950f..00d62ef2df3e 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/multi_arrays.py @@ -76,15 +76,13 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # override the default output from pydantic by calling `to_dict()` of each item in files (list) _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent.py index b8a5de498efe..6d952bc4d557 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent_with_optional_dict.py index 5193e6750c1f..073836419245 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent_with_optional_dict.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/pet.py index 95eb764baadb..ad545ecdd848 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/pet.py @@ -94,8 +94,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/property_map.py index d48ade5d9984..e34512b98d55 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/property_map.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/second_circular_all_of_ref.py index b56e8782933e..d8112af7e452 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/second_circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.circular_all_of_ref: for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) + _items.append(_item_circular_all_of_ref.to_dict() if _item_circular_all_of_ref is not None else None) _dict['circularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 4c79fe8bc7e5..100b8df77e60 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.dict_property: for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] + _field_dict_of_array[_key_dict_property] = [ + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] + ] if self.dict_property[_key_dict_property] is not None else None _dict['dictProperty'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index e4e4dbe21dea..c305a68c725f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -76,10 +76,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_dict = {} if self.map_of_map_non_primitive_property: for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): - if _value_map_of_map_non_primitive_property is not None: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { - _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() - } + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() + } if _value_map_of_map_non_primitive_property is not None else None _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index d2b83fbdb9d7..7337a96aa42c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -56,7 +56,7 @@ class Animal(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index ffdae49f239b..896229b2570a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] if _item_another_property is not None else None + ) _dict['another_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] + [Tag.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py index 3db556b3eb8a..8e03d5766e33 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_of_map_property: for _item_array_of_map_property in self.array_of_map_property: - if _item_array_of_map_property: - _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} - ) + _items.append( + {_inner_key: _inner_value.to_dict() if _inner_value is not None else None for _inner_key, _inner_value in _item_array_of_map_property.items()} if _item_array_of_map_property is not None else None + ) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +91,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "array_of_map_property": [ - {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["array_of_map_property"] ] if obj.get("array_of_map_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index b47021e9adb0..bb80aa6ab77d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -78,10 +78,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_array_of_model: for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] if _item_array_array_of_model is not None else None + ) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +98,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "array_of_nullable_float": obj.get("array_of_nullable_float"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index 3b8f10a664b0..955dd21246d4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -55,7 +55,7 @@ class BaseDiscriminator(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index a7ea1daf778d..69d6cfd2bdf4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.second_circular_all_of_ref: for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) + _items.append(_item_second_circular_all_of_ref.to_dict() if _item_second_circular_all_of_ref is not None else None) _dict['secondCircularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index e2af9fc33051..29cfc5e5f56c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -56,7 +56,7 @@ class Creature(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index ef7f96a4b4c3..275312d713ad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -54,7 +54,7 @@ class DiscriminatorAllOfSuper(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index 4c04c79dad7d..5e8ca6861d83 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index 2dd24cc67053..e03dd4fc3839 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index 8f8d882c67b3..e22e38fe0b59 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ + _item.to_dict() if _item is not None else None for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] + ] if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None else None _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index f1ef7f55ead3..20091d09ce86 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -78,8 +78,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() + _field_dict[_key_map] = self.map[_key_map].to_dict() if self.map[_key_map] is not None else None _dict['map'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index 0a3e337a950f..00d62ef2df3e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -76,15 +76,13 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # override the default output from pydantic by calling `to_dict()` of each item in files (list) _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index b8a5de498efe..6d952bc4d557 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 5193e6750c1f..073836419245 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index 95eb764baadb..ad545ecdd848 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -94,8 +94,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index d48ade5d9984..e34512b98d55 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index b56e8782933e..d8112af7e452 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -74,8 +74,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.circular_all_of_ref: for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) + _items.append(_item_circular_all_of_ref.to_dict() if _item_circular_all_of_ref is not None else None) _dict['circularAllOfRef'] = _items return _dict diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 4c79fe8bc7e5..100b8df77e60 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -74,10 +74,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.dict_property: for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] + _field_dict_of_array[_key_dict_property] = [ + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] + ] if self.dict_property[_key_dict_property] is not None else None _dict['dictProperty'] = _field_dict_of_array return _dict diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index 2f03e1fa1758..2971822badc4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -79,10 +79,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_dict = {} if self.map_of_map_non_primitive_property: for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): - if _value_map_of_map_non_primitive_property is not None: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { - _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() - } + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() + } if _value_map_of_map_non_primitive_property is not None else None _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index 562423002c0a..7c14179f558a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -57,7 +57,7 @@ class Animal(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index f290c6a19437..1cefcccf761d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] if _item_another_property is not None else None + ) _dict['another_property'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -100,7 +99,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] + [Tag.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py index 5f2639374f32..037ffbf014a3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_of_map_property: for _item_array_of_map_property in self.array_of_map_property: - if _item_array_of_map_property: - _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} - ) + _items.append( + {_inner_key: _inner_value.to_dict() if _inner_value is not None else None for _inner_key, _inner_value in _item_array_of_map_property.items()} if _item_array_of_map_property is not None else None + ) _dict['array_of_map_property'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -100,7 +99,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "array_of_map_property": [ - {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["array_of_map_property"] ] if obj.get("array_of_map_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index bbe20c814a4d..fe554557cff5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -81,10 +81,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_array_of_model: for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] if _item_array_array_of_model is not None else None + ) _dict['array_array_of_model'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -107,7 +106,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "array_of_nullable_float": obj.get("array_of_nullable_float"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index c1111f98976d..ab0e261bb049 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -56,7 +56,7 @@ class BaseDiscriminator(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index f03de1a2c7fb..3e025439e34a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.second_circular_all_of_ref: for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) + _items.append(_item_second_circular_all_of_ref.to_dict() if _item_second_circular_all_of_ref is not None else None) _dict['secondCircularAllOfRef'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index e8bcab1ec3f1..5f78af48d99f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -57,7 +57,7 @@ class Creature(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index 912682452989..d9aaad07ea17 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -55,7 +55,7 @@ class DiscriminatorAllOfSuper(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index 80da509938d5..a98f30c537bf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -81,8 +81,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index 4d1ff0e87aac..24c8f69713c6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index c6018ae272c6..153c0bf17d77 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ + _item.to_dict() if _item is not None else None for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] + ] if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None else None _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index 65da9a205120..d2f2dd57c55f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -81,8 +81,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() + _field_dict[_key_map] = self.map[_key_map].to_dict() if self.map[_key_map] is not None else None _dict['map'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index e1764bac50af..3f3c3a2c686f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -79,15 +79,13 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # override the default output from pydantic by calling `to_dict()` of each item in files (list) _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 8a9e22c1656d..03ff626ab76f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 742936312735..3a1a564dffa3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index 715e09680ba5..fc36d1b7ed2e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -97,8 +97,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index e72e32123334..8ecaaa6c029c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index 19116213fd5d..18346aee6fc9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.circular_all_of_ref: for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) + _items.append(_item_circular_all_of_ref.to_dict() if _item_circular_all_of_ref is not None else None) _dict['circularAllOfRef'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index cf6878baa1b9..19262db97625 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.dict_property: for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] + _field_dict_of_array[_key_dict_property] = [ + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] + ] if self.dict_property[_key_dict_property] is not None else None _dict['dictProperty'] = _field_dict_of_array # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 2f03e1fa1758..2971822badc4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -79,10 +79,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_dict = {} if self.map_of_map_non_primitive_property: for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): - if _value_map_of_map_non_primitive_property is not None: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { - _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() - } + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() + } if _value_map_of_map_non_primitive_property is not None else None _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 6ccf54936a8a..ddd3d5b91735 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -101,7 +101,7 @@ def __validate_input_names( @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index f290c6a19437..1cefcccf761d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] if _item_another_property is not None else None + ) _dict['another_property'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -100,7 +99,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] + [Tag.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py index 5f2639374f32..037ffbf014a3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_of_map_property: for _item_array_of_map_property in self.array_of_map_property: - if _item_array_of_map_property: - _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} - ) + _items.append( + {_inner_key: _inner_value.to_dict() if _inner_value is not None else None for _inner_key, _inner_value in _item_array_of_map_property.items()} if _item_array_of_map_property is not None else None + ) _dict['array_of_map_property'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -100,7 +99,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "array_of_map_property": [ - {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} if _item is not None else None for _item in obj["array_of_map_property"] ] if obj.get("array_of_map_property") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index bbe20c814a4d..fe554557cff5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -81,10 +81,9 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.array_array_of_model: for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) + _items.append( + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] if _item_array_array_of_model is not None else None + ) _dict['array_array_of_model'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -107,7 +106,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "array_of_nullable_float": obj.get("array_of_nullable_float"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] if _item is not None else None for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index c1111f98976d..ab0e261bb049 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -56,7 +56,7 @@ class BaseDiscriminator(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index f03de1a2c7fb..3e025439e34a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.second_circular_all_of_ref: for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) + _items.append(_item_second_circular_all_of_ref.to_dict() if _item_second_circular_all_of_ref is not None else None) _dict['secondCircularAllOfRef'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index e8bcab1ec3f1..5f78af48d99f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -57,7 +57,7 @@ class Creature(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index 912682452989..d9aaad07ea17 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -55,7 +55,7 @@ class DiscriminatorAllOfSuper(BaseModel): @classmethod def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: """Returns the discriminator value (object type) of the data""" - discriminator_value = obj[cls.__discriminator_property_name] + discriminator_value = obj.get(cls.__discriminator_property_name) if discriminator_value: return cls.__discriminator_value_class_map.get(discriminator_value) else: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index 80da509938d5..a98f30c537bf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -81,8 +81,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index 4d1ff0e87aac..24c8f69713c6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index c6018ae272c6..153c0bf17d77 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ + _item.to_dict() if _item is not None else None for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] + ] if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None else None _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 65da9a205120..d2f2dd57c55f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -81,8 +81,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() + _field_dict[_key_map] = self.map[_key_map].to_dict() if self.map[_key_map] is not None else None _dict['map'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index e1764bac50af..3f3c3a2c686f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -79,15 +79,13 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # override the default output from pydantic by calling `to_dict()` of each item in files (list) _items = [] if self.files: for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) + _items.append(_item_files.to_dict() if _item_files is not None else None) _dict['files'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 8a9e22c1656d..03ff626ab76f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 742936312735..3a1a564dffa3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.optional_dict: for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() if self.optional_dict[_key_optional_dict] is not None else None _dict['optionalDict'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 715e09680ba5..fc36d1b7ed2e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -97,8 +97,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.tags: for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) + _items.append(_item_tags.to_dict() if _item_tags is not None else None) _dict['tags'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index e72e32123334..8ecaaa6c029c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.some_data: for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() if self.some_data[_key_some_data] is not None else None _dict['some_data'] = _field_dict # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index 19116213fd5d..18346aee6fc9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -77,8 +77,7 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.circular_all_of_ref: for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) + _items.append(_item_circular_all_of_ref.to_dict() if _item_circular_all_of_ref is not None else None) _dict['circularAllOfRef'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index cf6878baa1b9..19262db97625 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -77,10 +77,9 @@ def to_dict(self) -> Dict[str, Any]: _field_dict_of_array = {} if self.dict_property: for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] + _field_dict_of_array[_key_dict_property] = [ + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] + ] if self.dict_property[_key_dict_property] is not None else None _dict['dictProperty'] = _field_dict_of_array # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: