From cfc25779f062246b9b46aec49399d4b35a7d8002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Mon, 20 Jul 2026 06:49:25 +0000 Subject: [PATCH 1/4] [python] fix null handling in generated models to_dict() rebuilt containers of models with truthiness checks, so None entries were dropped from lists (changing their length) and from dict values. Keep them as explicit nulls instead, and guard the list-of-list / list-of-dict from_dict comprehensions so a null inner container no longer crashes. from_dict() also used 'obj.get(k) is not None' when applying property defaults, which silently replaced an explicit JSON null with the schema default on nullable properties. Check key presence instead (nullable properties only, non-nullable keep the old behavior). get_discriminator_value() now uses obj.get() so a payload without the discriminator property raises the descriptive ValueError instead of a bare KeyError. --- .../resources/python/model_generic.mustache | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) 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..5a634e081ae0 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,12 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: + if _item_{{{name}}} is not None: _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] + [{{#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}}}] ) + else: + _items.append(None) _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.items.isPrimitiveType}} {{/items.isArray}} @@ -349,10 +351,12 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: + if _item_{{{name}}} is not None: _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()} + {_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()} ) + else: + _items.append(None) _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _items {{/items.items.isPrimitiveType}} {{/items.isMap}} @@ -364,8 +368,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}} @@ -381,8 +384,10 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb 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}}}] + {{#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}}}] ] + else: + _field_dict_of_array[_key_{{{name}}}] = None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_array {{/items.items.isPrimitiveType}} {{/items.isArray}} @@ -394,8 +399,10 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb 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() + _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() } + else: + _field_dict_of_dict[_key_{{{name}}}] = None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict_of_dict {{/items.items.isPrimitiveType}} {{/items.isMap}} @@ -407,8 +414,10 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _field_dict = {} if self.{{{name}}}: for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}]: + if self.{{{name}}}[_key_{{{name}}}] is not None: _field_dict[_key_{{{name}}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}[_key_{{{name}}}]){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}[_key_{{{name}}}].to_dict(){{/compatibleWithPythonLegacy}} + else: + _field_dict[_key_{{{name}}}] = None _dict[{{#lambda.pythonSingleQuotedStringLiteral}}{{{baseName}}}{{/lambda.pythonSingleQuotedStringLiteral}}] = _field_dict {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} @@ -512,7 +521,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 +532,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 +603,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}} From b34453785564e049031d246f0f6a0868472399bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Mon, 20 Jul 2026 06:49:31 +0000 Subject: [PATCH 2/4] update samples --- .../openapi_client/models/pet.py | 3 +- .../python/openapi_client/models/pet.py | 3 +- .../models/legacy_model.py | 31 ++++++++++++------- .../models/additional_properties_class.py | 4 ++- .../petstore_api/models/animal.py | 2 +- .../models/array_of_array_of_model.py | 8 +++-- .../petstore_api/models/array_of_map_model.py | 8 +++-- .../petstore_api/models/array_test.py | 8 +++-- .../petstore_api/models/base_discriminator.py | 2 +- .../models/circular_all_of_ref.py | 3 +- .../petstore_api/models/creature.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../models/file_schema_test_class.py | 3 +- .../petstore_api/models/input_all_of.py | 4 ++- .../models/map_of_array_of_model.py | 4 ++- ...perties_and_additional_properties_class.py | 4 ++- .../petstore_api/models/multi_arrays.py | 6 ++-- .../petstore_api/models/parent.py | 4 ++- .../models/parent_with_optional_dict.py | 4 ++- .../python-aiohttp/petstore_api/models/pet.py | 3 +- .../petstore_api/models/property_map.py | 4 ++- .../models/second_circular_all_of_ref.py | 3 +- ...t_with_additional_model_list_properties.py | 4 ++- .../models/additional_properties_class.py | 4 ++- .../petstore_api/models/animal.py | 2 +- .../models/array_of_array_of_model.py | 8 +++-- .../petstore_api/models/array_of_map_model.py | 8 +++-- .../petstore_api/models/array_test.py | 8 +++-- .../petstore_api/models/base_discriminator.py | 2 +- .../models/circular_all_of_ref.py | 3 +- .../petstore_api/models/creature.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../models/file_schema_test_class.py | 3 +- .../petstore_api/models/input_all_of.py | 4 ++- .../models/map_of_array_of_model.py | 4 ++- ...perties_and_additional_properties_class.py | 4 ++- .../petstore_api/models/multi_arrays.py | 6 ++-- .../petstore_api/models/parent.py | 4 ++- .../models/parent_with_optional_dict.py | 4 ++- .../petstore_api/models/pet.py | 3 +- .../petstore_api/models/property_map.py | 4 ++- .../models/second_circular_all_of_ref.py | 3 +- ...t_with_additional_model_list_properties.py | 4 ++- .../models/additional_properties_class.py | 4 ++- .../petstore_api/models/animal.py | 2 +- .../models/array_of_array_of_model.py | 8 +++-- .../petstore_api/models/array_of_map_model.py | 8 +++-- .../petstore_api/models/array_test.py | 8 +++-- .../petstore_api/models/base_discriminator.py | 2 +- .../models/circular_all_of_ref.py | 3 +- .../petstore_api/models/creature.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../models/file_schema_test_class.py | 3 +- .../petstore_api/models/input_all_of.py | 4 ++- .../models/map_of_array_of_model.py | 4 ++- ...perties_and_additional_properties_class.py | 4 ++- .../petstore_api/models/multi_arrays.py | 6 ++-- .../petstore_api/models/parent.py | 4 ++- .../models/parent_with_optional_dict.py | 4 ++- .../python-httpx/petstore_api/models/pet.py | 3 +- .../petstore_api/models/property_map.py | 4 ++- .../models/second_circular_all_of_ref.py | 3 +- ...t_with_additional_model_list_properties.py | 4 ++- .../models/additional_properties_class.py | 4 ++- .../petstore_api/models/animal.py | 2 +- .../models/array_of_array_of_model.py | 8 +++-- .../petstore_api/models/array_of_map_model.py | 8 +++-- .../petstore_api/models/array_test.py | 8 +++-- .../petstore_api/models/base_discriminator.py | 2 +- .../models/circular_all_of_ref.py | 3 +- .../petstore_api/models/creature.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../models/file_schema_test_class.py | 3 +- .../petstore_api/models/input_all_of.py | 4 ++- .../models/map_of_array_of_model.py | 4 ++- ...perties_and_additional_properties_class.py | 4 ++- .../petstore_api/models/multi_arrays.py | 6 ++-- .../petstore_api/models/parent.py | 4 ++- .../models/parent_with_optional_dict.py | 4 ++- .../petstore_api/models/pet.py | 3 +- .../petstore_api/models/property_map.py | 4 ++- .../models/second_circular_all_of_ref.py | 3 +- ...t_with_additional_model_list_properties.py | 4 ++- .../models/additional_properties_class.py | 4 ++- .../python/petstore_api/models/animal.py | 2 +- .../models/array_of_array_of_model.py | 8 +++-- .../petstore_api/models/array_of_map_model.py | 8 +++-- .../python/petstore_api/models/array_test.py | 8 +++-- .../petstore_api/models/base_discriminator.py | 2 +- .../models/circular_all_of_ref.py | 3 +- .../python/petstore_api/models/creature.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../models/file_schema_test_class.py | 3 +- .../petstore_api/models/input_all_of.py | 4 ++- .../models/map_of_array_of_model.py | 4 ++- ...perties_and_additional_properties_class.py | 4 ++- .../petstore_api/models/multi_arrays.py | 6 ++-- .../python/petstore_api/models/parent.py | 4 ++- .../models/parent_with_optional_dict.py | 4 ++- .../python/petstore_api/models/pet.py | 3 +- .../petstore_api/models/property_map.py | 4 ++- .../models/second_circular_all_of_ref.py | 3 +- ...t_with_additional_model_list_properties.py | 4 ++- 103 files changed, 267 insertions(+), 180 deletions(-) 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..349aa90850a0 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,33 +328,38 @@ 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]: + if self.nested_map[_key_nested_map] is not None: _field_dict[_key_nested_map] = _to_openapi_value(self.nested_map[_key_nested_map]) + else: + _field_dict[_key_nested_map] = 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: + if _item_nested_lists is not None: _items.append( - [_to_openapi_value(_inner_item) for _inner_item in _item_nested_lists if _inner_item is not None] + [_to_openapi_value(_inner_item) if _inner_item is not None else None for _inner_item in _item_nested_lists] ) + else: + _items.append(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: + if _item_nested_maps is not None: _items.append( - {_inner_key: _to_openapi_value(_inner_value) for _inner_key, _inner_value in _item_nested_maps.items()} + {_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()} ) + else: + _items.append(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 = {} @@ -362,8 +367,10 @@ def __openapi_generator_modern_projection(self) -> Dict[str, Any]: 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] + _to_openapi_value(_item) if _item is not None else None for _item in self.map_of_lists[_key_map_of_lists] ] + else: + _field_dict_of_array[_key_map_of_lists] = 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 = {} @@ -371,8 +378,10 @@ def __openapi_generator_modern_projection(self) -> Dict[str, Any]: 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() + _key: _to_openapi_value(_value) if _value is not None else None for _key, _value in _value_map_of_maps.items() } + else: + _field_dict_of_dict[_key_map_of_maps] = 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 +433,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..4992242e0eb2 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 @@ -78,8 +78,10 @@ def to_dict(self) -> Dict[str, Any]: 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() + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() } + else: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = 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..17d84001e33b 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,12 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: + if _item_another_property is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] ) + else: + _items.append(None) _dict['another_property'] = _items return _dict @@ -92,7 +94,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..c22b9a302256 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,12 @@ 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: + if _item_array_of_map_property is not None: _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + {_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()} ) + else: + _items.append(None) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +94,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..180a53c803b9 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,12 @@ 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: + if _item_array_array_of_model is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] ) + else: + _items.append(None) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +101,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..414d8344bea3 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..1b21d12f2278 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _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] ] + else: + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = 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..6f54eb8e9131 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,10 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: + if self.map[_key_map] is not None: _field_dict[_key_map] = self.map[_key_map].to_dict() + else: + _field_dict[_key_map] = 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..514a6b81ed22 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..ac370a031fce 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..914af0390b47 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..598bbcbb85f0 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] ] + else: + _field_dict_of_array[_key_dict_property] = 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..4992242e0eb2 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 @@ -78,8 +78,10 @@ def to_dict(self) -> Dict[str, Any]: 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() + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() } + else: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = 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..17d84001e33b 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,12 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: + if _item_another_property is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] ) + else: + _items.append(None) _dict['another_property'] = _items return _dict @@ -92,7 +94,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..c22b9a302256 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,12 @@ 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: + if _item_array_of_map_property is not None: _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + {_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()} ) + else: + _items.append(None) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +94,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..180a53c803b9 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,12 @@ 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: + if _item_array_array_of_model is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] ) + else: + _items.append(None) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +101,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..414d8344bea3 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..1b21d12f2278 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _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] ] + else: + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = 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..6f54eb8e9131 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,10 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: + if self.map[_key_map] is not None: _field_dict[_key_map] = self.map[_key_map].to_dict() + else: + _field_dict[_key_map] = 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..514a6b81ed22 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..ac370a031fce 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..914af0390b47 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..598bbcbb85f0 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] ] + else: + _field_dict_of_array[_key_dict_property] = 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..4992242e0eb2 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 @@ -78,8 +78,10 @@ def to_dict(self) -> Dict[str, Any]: 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() + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() } + else: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = 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..17d84001e33b 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,12 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: + if _item_another_property is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] ) + else: + _items.append(None) _dict['another_property'] = _items return _dict @@ -92,7 +94,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..c22b9a302256 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,12 @@ 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: + if _item_array_of_map_property is not None: _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + {_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()} ) + else: + _items.append(None) _dict['array_of_map_property'] = _items return _dict @@ -92,7 +94,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..180a53c803b9 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,12 @@ 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: + if _item_array_array_of_model is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] ) + else: + _items.append(None) _dict['array_array_of_model'] = _items return _dict @@ -99,7 +101,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..414d8344bea3 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..1b21d12f2278 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _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] ] + else: + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = 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..6f54eb8e9131 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,10 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: + if self.map[_key_map] is not None: _field_dict[_key_map] = self.map[_key_map].to_dict() + else: + _field_dict[_key_map] = 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..514a6b81ed22 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..ac370a031fce 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..914af0390b47 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..598bbcbb85f0 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 @@ -76,8 +76,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] ] + else: + _field_dict_of_array[_key_dict_property] = 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..73f7f582c56f 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 @@ -81,8 +81,10 @@ def to_dict(self) -> Dict[str, Any]: 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() + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() } + else: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = 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..0b2180128fbd 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,12 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: + if _item_another_property is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] ) + else: + _items.append(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 +102,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..3582fb1a48f3 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,12 @@ 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: + if _item_array_of_map_property is not None: _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + {_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()} ) + else: + _items.append(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 +102,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..8e08c5671d4a 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,12 @@ 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: + if _item_array_array_of_model is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] ) + else: + _items.append(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 +109,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..735b7ea26008 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..83f934c2ec2b 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 @@ -79,8 +79,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _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] ] + else: + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = 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..d5b38c5b417b 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,10 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: + if self.map[_key_map] is not None: _field_dict[_key_map] = self.map[_key_map].to_dict() + else: + _field_dict[_key_map] = 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..3a7e980cb00f 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..ed166f3363f0 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..cc726f3203b2 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..25431283359a 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 @@ -79,8 +79,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] ] + else: + _field_dict_of_array[_key_dict_property] = 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..73f7f582c56f 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 @@ -81,8 +81,10 @@ def to_dict(self) -> Dict[str, Any]: 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() + _key: _value.to_dict() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() } + else: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = 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..0b2180128fbd 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,12 @@ def to_dict(self) -> Dict[str, Any]: _items = [] if self.another_property: for _item_another_property in self.another_property: - if _item_another_property: + if _item_another_property is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] ) + else: + _items.append(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 +102,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..3582fb1a48f3 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,12 @@ 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: + if _item_array_of_map_property is not None: _items.append( - {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + {_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()} ) + else: + _items.append(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 +102,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..8e08c5671d4a 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,12 @@ 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: + if _item_array_array_of_model is not None: _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] + [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_array_array_of_model] ) + else: + _items.append(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 +109,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..735b7ea26008 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..83f934c2ec2b 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 @@ -79,8 +79,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _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] ] + else: + _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = 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..d5b38c5b417b 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,10 @@ def to_dict(self) -> Dict[str, Any]: _field_dict = {} if self.map: for _key_map in self.map: - if self.map[_key_map]: + if self.map[_key_map] is not None: _field_dict[_key_map] = self.map[_key_map].to_dict() + else: + _field_dict[_key_map] = 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..3a7e980cb00f 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..ed166f3363f0 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,10 @@ 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]: + if self.optional_dict[_key_optional_dict] is not None: _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() + else: + _field_dict[_key_optional_dict] = 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..cc726f3203b2 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,10 @@ 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]: + if self.some_data[_key_some_data] is not None: _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() + else: + _field_dict[_key_some_data] = 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..25431283359a 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 @@ -79,8 +79,10 @@ def to_dict(self) -> Dict[str, Any]: 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] + _item.to_dict() if _item is not None else None for _item in self.dict_property[_key_dict_property] ] + else: + _field_dict_of_array[_key_dict_property] = 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: From d6bd2d14dd04e1c38aef5f8eaeecc7c97b916870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Mon, 20 Jul 2026 07:22:26 +0000 Subject: [PATCH 3/4] [python] keep container to_dict mypy-clean when preserving nulls The previous commit added an else-branch that assigned None to the per-key accumulators (e.g. _field_dict_of_array[k] = None). mypy fixes the dict value type from the first non-None assignment, so the None branch tripped 'Incompatible types in assignment' on the legacy-model-dictionaries sample. Fold each container branch into a single conditional expression so the accumulator is inferred as Optional from the start. Same output, same null-preserving behaviour. --- .../resources/python/model_generic.mustache | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) 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 5a634e081ae0..3d1758ac7ec6 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -336,12 +336,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}} 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}}}] - ) - else: - _items.append(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}} @@ -351,12 +348,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _items = [] if self.{{{name}}}: for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}} is not None: - _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()} - ) - else: - _items.append(None) + _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}} @@ -382,12 +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}} if _item is not None else None for _item in self.{{{name}}}[_key_{{{name}}}] - ] - else: - _field_dict_of_array[_key_{{{name}}}] = None + _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}} @@ -397,12 +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}} if _value is not None else None for _key, _value in _value_{{{name}}}.items() - } - else: - _field_dict_of_dict[_key_{{{name}}}] = None + _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}} @@ -414,10 +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}}}] is not None: - _field_dict[_key_{{{name}}}] = {{#compatibleWithPythonLegacy}}_to_openapi_value(self.{{{name}}}[_key_{{{name}}}]){{/compatibleWithPythonLegacy}}{{^compatibleWithPythonLegacy}}self.{{{name}}}[_key_{{{name}}}].to_dict(){{/compatibleWithPythonLegacy}} - else: - _field_dict[_key_{{{name}}}] = None + _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}} From 4040d87b749cc8b6b43f2cc07f1d025b7f9f1d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Mon, 20 Jul 2026 07:22:27 +0000 Subject: [PATCH 4/4] update samples --- .../models/legacy_model.py | 41 ++++++------------- .../models/additional_properties_class.py | 9 ++-- .../models/array_of_array_of_model.py | 9 ++-- .../petstore_api/models/array_of_map_model.py | 9 ++-- .../petstore_api/models/array_test.py | 9 ++-- .../petstore_api/models/input_all_of.py | 5 +-- .../models/map_of_array_of_model.py | 9 ++-- ...perties_and_additional_properties_class.py | 5 +-- .../petstore_api/models/parent.py | 5 +-- .../models/parent_with_optional_dict.py | 5 +-- .../petstore_api/models/property_map.py | 5 +-- ...t_with_additional_model_list_properties.py | 9 ++-- .../models/additional_properties_class.py | 9 ++-- .../models/array_of_array_of_model.py | 9 ++-- .../petstore_api/models/array_of_map_model.py | 9 ++-- .../petstore_api/models/array_test.py | 9 ++-- .../petstore_api/models/input_all_of.py | 5 +-- .../models/map_of_array_of_model.py | 9 ++-- ...perties_and_additional_properties_class.py | 5 +-- .../petstore_api/models/parent.py | 5 +-- .../models/parent_with_optional_dict.py | 5 +-- .../petstore_api/models/property_map.py | 5 +-- ...t_with_additional_model_list_properties.py | 9 ++-- .../models/additional_properties_class.py | 9 ++-- .../models/array_of_array_of_model.py | 9 ++-- .../petstore_api/models/array_of_map_model.py | 9 ++-- .../petstore_api/models/array_test.py | 9 ++-- .../petstore_api/models/input_all_of.py | 5 +-- .../models/map_of_array_of_model.py | 9 ++-- ...perties_and_additional_properties_class.py | 5 +-- .../petstore_api/models/parent.py | 5 +-- .../models/parent_with_optional_dict.py | 5 +-- .../petstore_api/models/property_map.py | 5 +-- ...t_with_additional_model_list_properties.py | 9 ++-- .../models/additional_properties_class.py | 9 ++-- .../models/array_of_array_of_model.py | 9 ++-- .../petstore_api/models/array_of_map_model.py | 9 ++-- .../petstore_api/models/array_test.py | 9 ++-- .../petstore_api/models/input_all_of.py | 5 +-- .../models/map_of_array_of_model.py | 9 ++-- ...perties_and_additional_properties_class.py | 5 +-- .../petstore_api/models/parent.py | 5 +-- .../models/parent_with_optional_dict.py | 5 +-- .../petstore_api/models/property_map.py | 5 +-- ...t_with_additional_model_list_properties.py | 9 ++-- .../models/additional_properties_class.py | 9 ++-- .../models/array_of_array_of_model.py | 9 ++-- .../petstore_api/models/array_of_map_model.py | 9 ++-- .../python/petstore_api/models/array_test.py | 9 ++-- .../petstore_api/models/input_all_of.py | 5 +-- .../models/map_of_array_of_model.py | 9 ++-- ...perties_and_additional_properties_class.py | 5 +-- .../python/petstore_api/models/parent.py | 5 +-- .../models/parent_with_optional_dict.py | 5 +-- .../petstore_api/models/property_map.py | 5 +-- ...t_with_additional_model_list_properties.py | 9 ++-- 56 files changed, 128 insertions(+), 308 deletions(-) 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 349aa90850a0..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 @@ -334,54 +334,39 @@ def __openapi_generator_modern_projection(self) -> Dict[str, Any]: _field_dict = {} if self.nested_map: for _key_nested_map in self.nested_map: - if self.nested_map[_key_nested_map] is not None: - _field_dict[_key_nested_map] = _to_openapi_value(self.nested_map[_key_nested_map]) - else: - _field_dict[_key_nested_map] = None + _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 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] - ) - else: - _items.append(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 is not None: - _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()} - ) - else: - _items.append(None) + _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) if _item is not None else None for _item in self.map_of_lists[_key_map_of_lists] - ] - else: - _field_dict_of_array[_key_map_of_lists] = None + _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) if _value is not None else None for _key, _value in _value_map_of_maps.items() - } - else: - _field_dict_of_dict[_key_map_of_maps] = None + _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 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 4992242e0eb2..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,12 +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() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() - } - else: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = None + _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/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 17d84001e33b..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,12 +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 is not None: - _items.append( - [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] - ) - else: - _items.append(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 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 c22b9a302256..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,12 +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 is not None: - _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()} - ) - else: - _items.append(None) + _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 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 180a53c803b9..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,12 +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 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] - ) - else: - _items.append(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 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 414d8344bea3..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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 1b21d12f2278..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,12 +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() 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] - ] - else: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = None + _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 6f54eb8e9131..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,10 +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] is not None: - _field_dict[_key_map] = self.map[_key_map].to_dict() - else: - _field_dict[_key_map] = None + _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/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 514a6b81ed22..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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 ac370a031fce..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index 914af0390b47..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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/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 598bbcbb85f0..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,12 +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() if _item is not None else None for _item in self.dict_property[_key_dict_property] - ] - else: - _field_dict_of_array[_key_dict_property] = None + _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 4992242e0eb2..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,12 +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() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() - } - else: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = None + _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/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/array_of_array_of_model.py index 17d84001e33b..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,12 +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 is not None: - _items.append( - [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] - ) - else: - _items.append(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 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 c22b9a302256..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,12 +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 is not None: - _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()} - ) - else: - _items.append(None) + _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 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 180a53c803b9..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,12 +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 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] - ) - else: - _items.append(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 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 414d8344bea3..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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 1b21d12f2278..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,12 +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() 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] - ] - else: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = None + _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 6f54eb8e9131..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,10 +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] is not None: - _field_dict[_key_map] = self.map[_key_map].to_dict() - else: - _field_dict[_key_map] = None + _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/parent.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/parent.py index 514a6b81ed22..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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 ac370a031fce..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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/property_map.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/property_map.py index 914af0390b47..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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/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 598bbcbb85f0..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,12 +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() if _item is not None else None for _item in self.dict_property[_key_dict_property] - ] - else: - _field_dict_of_array[_key_dict_property] = None + _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 4992242e0eb2..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,12 +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() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() - } - else: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = None + _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/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index 17d84001e33b..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,12 +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 is not None: - _items.append( - [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] - ) - else: - _items.append(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 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 c22b9a302256..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,12 +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 is not None: - _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()} - ) - else: - _items.append(None) + _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 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 180a53c803b9..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,12 +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 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] - ) - else: - _items.append(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 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 414d8344bea3..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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 1b21d12f2278..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,12 +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() 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] - ] - else: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = None + _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 6f54eb8e9131..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,10 +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] is not None: - _field_dict[_key_map] = self.map[_key_map].to_dict() - else: - _field_dict[_key_map] = None + _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/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 514a6b81ed22..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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 ac370a031fce..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index 914af0390b47..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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/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 598bbcbb85f0..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,12 +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() if _item is not None else None for _item in self.dict_property[_key_dict_property] - ] - else: - _field_dict_of_array[_key_dict_property] = None + _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 73f7f582c56f..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,12 +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() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() - } - else: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = None + _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/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 0b2180128fbd..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,12 +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 is not None: - _items.append( - [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] - ) - else: - _items.append(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: 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 3582fb1a48f3..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,12 +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 is not None: - _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()} - ) - else: - _items.append(None) + _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: 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 8e08c5671d4a..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,12 +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 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] - ) - else: - _items.append(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: 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 735b7ea26008..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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 83f934c2ec2b..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,12 +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() 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] - ] - else: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = None + _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 d5b38c5b417b..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,10 +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] is not None: - _field_dict[_key_map] = self.map[_key_map].to_dict() - else: - _field_dict[_key_map] = None + _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/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 3a7e980cb00f..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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 ed166f3363f0..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index cc726f3203b2..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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/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 25431283359a..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,12 +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() if _item is not None else None for _item in self.dict_property[_key_dict_property] - ] - else: - _field_dict_of_array[_key_dict_property] = None + _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 73f7f582c56f..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,12 +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() if _value is not None else None for _key, _value in _value_map_of_map_non_primitive_property.items() - } - else: - _field_dict_of_dict[_key_map_of_map_non_primitive_property] = None + _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/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 0b2180128fbd..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,12 +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 is not None: - _items.append( - [_inner_item.to_dict() if _inner_item is not None else None for _inner_item in _item_another_property] - ) - else: - _items.append(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: 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 3582fb1a48f3..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,12 +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 is not None: - _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()} - ) - else: - _items.append(None) + _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: 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 8e08c5671d4a..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,12 +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 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] - ) - else: - _items.append(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: 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 735b7ea26008..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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 83f934c2ec2b..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,12 +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() 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] - ] - else: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = None + _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 d5b38c5b417b..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,10 +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] is not None: - _field_dict[_key_map] = self.map[_key_map].to_dict() - else: - _field_dict[_key_map] = None + _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/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 3a7e980cb00f..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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 ed166f3363f0..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,10 +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] is not None: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - else: - _field_dict[_key_optional_dict] = None + _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/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index cc726f3203b2..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,10 +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] is not None: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - else: - _field_dict[_key_some_data] = None + _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/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 25431283359a..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,12 +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() if _item is not None else None for _item in self.dict_property[_key_dict_property] - ] - else: - _field_dict_of_array[_key_dict_property] = None + _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: