Skip to content

Commit 384ff94

Browse files
fix: Merge conflict from #16779 and #16777 (#16784)
1 parent 2b6b3b0 commit 384ff94

4 files changed

Lines changed: 68 additions & 26 deletions

File tree

samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,22 @@ def from_json(cls, json_str: str) -> Self:
5555
"""Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string"""
5656
return cls.from_dict(json.loads(json_str))
5757

58-
def to_dict(self):
59-
"""Returns the dictionary representation of the model using alias"""
60-
_dict = self.model_dump(by_alias=True,
61-
exclude={
62-
},
63-
exclude_none=True)
58+
def to_dict(self) -> Dict[str, Any]:
59+
"""Return the dictionary representation of the model using alias.
60+
61+
This has the following differences from calling pydantic's
62+
`self.model_dump(by_alias=True)`:
63+
64+
* `None` is only added to the output dict for nullable fields that
65+
were set at model initialization. Other fields with value `None`
66+
are ignored.
67+
"""
68+
_dict = self.model_dump(
69+
by_alias=True,
70+
exclude={
71+
},
72+
exclude_none=True,
73+
)
6474
# override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array)
6575
_field_dict_of_array = {}
6676
if self.dict_property:

samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,22 @@ def from_json(cls, json_str: str) -> Self:
5454
"""Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string"""
5555
return cls.from_dict(json.loads(json_str))
5656

57-
def to_dict(self):
58-
"""Returns the dictionary representation of the model using alias"""
59-
_dict = self.model_dump(by_alias=True,
60-
exclude={
61-
},
62-
exclude_none=True)
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias.
59+
60+
This has the following differences from calling pydantic's
61+
`self.model_dump(by_alias=True)`:
62+
63+
* `None` is only added to the output dict for nullable fields that
64+
were set at model initialization. Other fields with value `None`
65+
are ignored.
66+
"""
67+
_dict = self.model_dump(
68+
by_alias=True,
69+
exclude={
70+
},
71+
exclude_none=True,
72+
)
6373
return _dict
6474

6575
@classmethod

samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,24 @@ def from_json(cls, json_str: str) -> Self:
5656
"""Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string"""
5757
return cls.from_dict(json.loads(json_str))
5858

59-
def to_dict(self):
60-
"""Returns the dictionary representation of the model using alias"""
61-
_dict = self.model_dump(by_alias=True,
62-
exclude={
63-
"additional_properties"
64-
},
65-
exclude_none=True)
59+
def to_dict(self) -> Dict[str, Any]:
60+
"""Return the dictionary representation of the model using alias.
61+
62+
This has the following differences from calling pydantic's
63+
`self.model_dump(by_alias=True)`:
64+
65+
* `None` is only added to the output dict for nullable fields that
66+
were set at model initialization. Other fields with value `None`
67+
are ignored.
68+
* Fields in `self.additional_properties` are added to the output dict.
69+
"""
70+
_dict = self.model_dump(
71+
by_alias=True,
72+
exclude={
73+
"additional_properties",
74+
},
75+
exclude_none=True,
76+
)
6677
# override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array)
6778
_field_dict_of_array = {}
6879
if self.dict_property:

samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,24 @@ def from_json(cls, json_str: str) -> Self:
5555
"""Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string"""
5656
return cls.from_dict(json.loads(json_str))
5757

58-
def to_dict(self):
59-
"""Returns the dictionary representation of the model using alias"""
60-
_dict = self.model_dump(by_alias=True,
61-
exclude={
62-
"additional_properties"
63-
},
64-
exclude_none=True)
58+
def to_dict(self) -> Dict[str, Any]:
59+
"""Return the dictionary representation of the model using alias.
60+
61+
This has the following differences from calling pydantic's
62+
`self.model_dump(by_alias=True)`:
63+
64+
* `None` is only added to the output dict for nullable fields that
65+
were set at model initialization. Other fields with value `None`
66+
are ignored.
67+
* Fields in `self.additional_properties` are added to the output dict.
68+
"""
69+
_dict = self.model_dump(
70+
by_alias=True,
71+
exclude={
72+
"additional_properties",
73+
},
74+
exclude_none=True,
75+
)
6576
# puts key-value pairs in additional_properties in the top level
6677
if self.additional_properties is not None:
6778
for _key, _value in self.additional_properties.items():

0 commit comments

Comments
 (0)