Skip to content

Commit 520434f

Browse files
committed
update python samples
1 parent f370901 commit 520434f

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from petstore_api.models.tag import Tag
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class ArrayOfMapModel(BaseModel):
2728
"""
@@ -44,8 +45,7 @@ def to_str(self) -> str:
4445

4546
def to_json(self) -> str:
4647
"""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())
48+
return json.dumps(to_jsonable_python(self.to_dict()))
4949

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from uuid import UUID
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class UuidWithPattern(BaseModel):
2728
"""
@@ -54,8 +55,7 @@ def to_str(self) -> str:
5455

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

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

samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from petstore_api.models.tag import Tag
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class ArrayOfMapModel(BaseModel):
2728
"""
@@ -44,8 +45,7 @@ def to_str(self) -> str:
4445

4546
def to_json(self) -> str:
4647
"""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())
48+
return json.dumps(to_jsonable_python(self.to_dict()))
4949

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

samples/openapi3/client/petstore/python-httpx/petstore_api/models/uuid_with_pattern.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from uuid import UUID
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class UuidWithPattern(BaseModel):
2728
"""
@@ -54,8 +55,7 @@ def to_str(self) -> str:
5455

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

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

samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from petstore_api.models.tag import Tag
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class ArrayOfMapModel(BaseModel):
2728
"""
@@ -45,8 +46,7 @@ def to_str(self) -> str:
4546

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

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

samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/uuid_with_pattern.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from uuid import UUID
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class UuidWithPattern(BaseModel):
2728
"""
@@ -55,8 +56,7 @@ def to_str(self) -> str:
5556

5657
def to_json(self) -> str:
5758
"""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())
59+
return json.dumps(to_jsonable_python(self.to_dict()))
6060

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from petstore_api.models.tag import Tag
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class ArrayOfMapModel(BaseModel):
2728
"""
@@ -45,8 +46,7 @@ def to_str(self) -> str:
4546

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

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from uuid import UUID
2323
from typing import Optional, Set
2424
from typing_extensions import Self
25+
from pydantic_core import to_jsonable_python
2526

2627
class UuidWithPattern(BaseModel):
2728
"""
@@ -55,8 +56,7 @@ def to_str(self) -> str:
5556

5657
def to_json(self) -> str:
5758
"""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())
59+
return json.dumps(to_jsonable_python(self.to_dict()))
6060

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

0 commit comments

Comments
 (0)