Skip to content

Commit 370e53e

Browse files
committed
Update Python samples to use Pydantic .model_dump_json
1 parent befb80c commit 370e53e

382 files changed

Lines changed: 382 additions & 764 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def to_str(self) -> str:
4444

4545
def to_json(self) -> str:
4646
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
47+
return self.model_dump_json(by_alias=True, exclude_unset=True)
4948

5049
@classmethod
5150
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def to_str(self) -> str:
4444

4545
def to_json(self) -> str:
4646
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
47+
return self.model_dump_json(by_alias=True, exclude_unset=True)
4948

5049
@classmethod
5150
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def to_str(self) -> str:
4747

4848
def to_json(self) -> str:
4949
"""Returns the JSON representation of the model using alias"""
50-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
51-
return json.dumps(self.to_dict())
50+
return self.model_dump_json(by_alias=True, exclude_unset=True)
5251

5352
@classmethod
5453
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def to_str(self) -> str:
6262

6363
def to_json(self) -> str:
6464
"""Returns the JSON representation of the model using alias"""
65-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66-
return json.dumps(self.to_dict())
65+
return self.model_dump_json(by_alias=True, exclude_unset=True)
6766

6867
@classmethod
6968
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def to_str(self) -> str:
4646

4747
def to_json(self) -> str:
4848
"""Returns the JSON representation of the model using alias"""
49-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50-
return json.dumps(self.to_dict())
49+
return self.model_dump_json(by_alias=True, exclude_unset=True)
5150

5251
@classmethod
5352
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def to_str(self) -> str:
6060

6161
def to_json(self) -> str:
6262
"""Returns the JSON representation of the model using alias"""
63-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
64-
return json.dumps(self.to_dict())
63+
return self.model_dump_json(by_alias=True, exclude_unset=True)
6564

6665
@classmethod
6766
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def to_str(self) -> str:
5555

5656
def to_json(self) -> str:
5757
"""Returns the JSON representation of the model using alias"""
58-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
59-
return json.dumps(self.to_dict())
58+
return self.model_dump_json(by_alias=True, exclude_unset=True)
6059

6160
@classmethod
6261
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def to_str(self) -> str:
4444

4545
def to_json(self) -> str:
4646
"""Returns the JSON representation of the model using alias"""
47-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48-
return json.dumps(self.to_dict())
47+
return self.model_dump_json(by_alias=True, exclude_unset=True)
4948

5049
@classmethod
5150
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def to_str(self) -> str:
4343

4444
def to_json(self) -> str:
4545
"""Returns the JSON representation of the model using alias"""
46-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47-
return json.dumps(self.to_dict())
46+
return self.model_dump_json(by_alias=True, exclude_unset=True)
4847

4948
@classmethod
5049
def from_json(cls, json_str: str) -> Optional[Self]:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def to_str(self) -> str:
4646

4747
def to_json(self) -> str:
4848
"""Returns the JSON representation of the model using alias"""
49-
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50-
return json.dumps(self.to_dict())
49+
return self.model_dump_json(by_alias=True, exclude_unset=True)
5150

5251
@classmethod
5352
def from_json(cls, json_str: str) -> Optional[Self]:

0 commit comments

Comments
 (0)