Skip to content

Commit a925bbd

Browse files
committed
[REF] model_generic.mustache
1 parent 06f5b7c commit a925bbd

392 files changed

Lines changed: 1924 additions & 1924 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.

modules/openapi-generator/src/main/resources/python/model_anyof.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ from __future__ import annotations
55
{{#vendorExtensions.x-py-model-imports}}
66
{{{.}}}
77
{{/vendorExtensions.x-py-model-imports}}
8+
from pydantic import Field, RootModel
89
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
910
from typing_extensions import Literal, Self
10-
from pydantic import Field, RootModel
1111

1212
{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]
1313

modules/openapi-generator/src/main/resources/python/model_generic.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
166166
"""Returns the object represented by the json string"""
167167
return cls.model_validate_json(json_str)
168168

169-
def to_json(self) -> str:
170-
"""Returns the JSON representation of the actual instance"""
171-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
172-
173169
def to_dict(self) -> Dict[str, Any]:
174170
"""Returns the dict representation of the actual instance"""
175171
return self.model_dump(by_alias=True)
176172

173+
def to_json(self) -> str:
174+
"""Returns the JSON representation of the actual instance"""
175+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
176+
177177
def to_str(self) -> str:
178178
"""Returns the string representation of the model using alias"""
179-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
179+
return pprint.pformat(self.to_json())
180180

181181

182182
{{#vendorExtensions.x-py-postponed-model-imports.size}}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self:
4949
"""Returns the object represented by the json string"""
5050
return cls.model_validate_json(json_str)
5151

52-
def to_json(self) -> str:
53-
"""Returns the JSON representation of the actual instance"""
54-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
55-
5652
def to_dict(self) -> Dict[str, Any]:
5753
"""Returns the dict representation of the actual instance"""
5854
return self.model_dump(by_alias=True)
5955

56+
def to_json(self) -> str:
57+
"""Returns the JSON representation of the actual instance"""
58+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
59+
6060
def to_str(self) -> str:
6161
"""Returns the string representation of the model using alias"""
62-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
62+
return pprint.pformat(self.to_json())
6363

6464

6565

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self:
4949
"""Returns the object represented by the json string"""
5050
return cls.model_validate_json(json_str)
5151

52-
def to_json(self) -> str:
53-
"""Returns the JSON representation of the actual instance"""
54-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
55-
5652
def to_dict(self) -> Dict[str, Any]:
5753
"""Returns the dict representation of the actual instance"""
5854
return self.model_dump(by_alias=True)
5955

56+
def to_json(self) -> str:
57+
"""Returns the JSON representation of the actual instance"""
58+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
59+
6060
def to_str(self) -> str:
6161
"""Returns the string representation of the model using alias"""
62-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
62+
return pprint.pformat(self.to_json())
6363

6464

6565

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self:
5252
"""Returns the object represented by the json string"""
5353
return cls.model_validate_json(json_str)
5454

55-
def to_json(self) -> str:
56-
"""Returns the JSON representation of the actual instance"""
57-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
58-
5955
def to_dict(self) -> Dict[str, Any]:
6056
"""Returns the dict representation of the actual instance"""
6157
return self.model_dump(by_alias=True)
6258

59+
def to_json(self) -> str:
60+
"""Returns the JSON representation of the actual instance"""
61+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
62+
6363
def to_str(self) -> str:
6464
"""Returns the string representation of the model using alias"""
65-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
65+
return pprint.pformat(self.to_json())
6666

6767

6868

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self:
7070
"""Returns the object represented by the json string"""
7171
return cls.model_validate_json(json_str)
7272

73-
def to_json(self) -> str:
74-
"""Returns the JSON representation of the actual instance"""
75-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
76-
7773
def to_dict(self) -> Dict[str, Any]:
7874
"""Returns the dict representation of the actual instance"""
7975
return self.model_dump(by_alias=True)
8076

77+
def to_json(self) -> str:
78+
"""Returns the JSON representation of the actual instance"""
79+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
80+
8181
def to_str(self) -> str:
8282
"""Returns the string representation of the model using alias"""
83-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
83+
return pprint.pformat(self.to_json())
8484

8585

8686

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self:
5151
"""Returns the object represented by the json string"""
5252
return cls.model_validate_json(json_str)
5353

54-
def to_json(self) -> str:
55-
"""Returns the JSON representation of the actual instance"""
56-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
57-
5854
def to_dict(self) -> Dict[str, Any]:
5955
"""Returns the dict representation of the actual instance"""
6056
return self.model_dump(by_alias=True)
6157

58+
def to_json(self) -> str:
59+
"""Returns the JSON representation of the actual instance"""
60+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
61+
6262
def to_str(self) -> str:
6363
"""Returns the string representation of the model using alias"""
64-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
64+
return pprint.pformat(self.to_json())
6565

6666

6767

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self:
6868
"""Returns the object represented by the json string"""
6969
return cls.model_validate_json(json_str)
7070

71-
def to_json(self) -> str:
72-
"""Returns the JSON representation of the actual instance"""
73-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
74-
7571
def to_dict(self) -> Dict[str, Any]:
7672
"""Returns the dict representation of the actual instance"""
7773
return self.model_dump(by_alias=True)
7874

75+
def to_json(self) -> str:
76+
"""Returns the JSON representation of the actual instance"""
77+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
78+
7979
def to_str(self) -> str:
8080
"""Returns the string representation of the model using alias"""
81-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
81+
return pprint.pformat(self.to_json())
8282

8383

8484

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self:
6363
"""Returns the object represented by the json string"""
6464
return cls.model_validate_json(json_str)
6565

66-
def to_json(self) -> str:
67-
"""Returns the JSON representation of the actual instance"""
68-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
69-
7066
def to_dict(self) -> Dict[str, Any]:
7167
"""Returns the dict representation of the actual instance"""
7268
return self.model_dump(by_alias=True)
7369

70+
def to_json(self) -> str:
71+
"""Returns the JSON representation of the actual instance"""
72+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
73+
7474
def to_str(self) -> str:
7575
"""Returns the string representation of the model using alias"""
76-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
76+
return pprint.pformat(self.to_json())
7777

7878

7979

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self:
4949
"""Returns the object represented by the json string"""
5050
return cls.model_validate_json(json_str)
5151

52-
def to_json(self) -> str:
53-
"""Returns the JSON representation of the actual instance"""
54-
return json.dumps(self.model_dump(by_alias=True, exclude_none=True))
55-
5652
def to_dict(self) -> Dict[str, Any]:
5753
"""Returns the dict representation of the actual instance"""
5854
return self.model_dump(by_alias=True)
5955

56+
def to_json(self) -> str:
57+
"""Returns the JSON representation of the actual instance"""
58+
return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
59+
6060
def to_str(self) -> str:
6161
"""Returns the string representation of the model using alias"""
62-
return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json"))
62+
return pprint.pformat(self.to_json())
6363

6464

6565

0 commit comments

Comments
 (0)