diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index f8f3e8f10ee1..0c391c0071f7 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -15,6 +15,10 @@ import re # noqa: F401 from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] @@ -97,13 +101,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v @classmethod - def from_dict(cls, obj: dict) -> {{{classname}}}: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> {{{classname}}}: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = {{{classname}}}.model_construct() + instance = cls.model_construct() {{#isNullable}} if json_str is None: return instance diff --git a/modules/openapi-generator/src/main/resources/python/model_enum.mustache b/modules/openapi-generator/src/main/resources/python/model_enum.mustache index 8a59dd5bc7ef..0bd7dafbeef8 100644 --- a/modules/openapi-generator/src/main/resources/python/model_enum.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_enum.mustache @@ -6,6 +6,10 @@ from enum import Enum {{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}} {{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}} {{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}} +try: + from typing import Self +except ImportError: + from typing_extensions import Self class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum): @@ -22,9 +26,9 @@ class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum): {{/enumVars}} @classmethod - def from_json(cls, json_str: str) -> {{{classname}}}: + def from_json(cls, json_str: str) -> Self: """Create an instance of {{classname}} from a JSON string""" - return {{classname}}(json.loads(json_str)) + return cls(json.loads(json_str)) {{#defaultValue}} 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 290127045b7b..28515d1466aa 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -12,6 +12,11 @@ import json {{#vendorExtensions.x-py-model-imports}} {{{.}}} {{/vendorExtensions.x-py-model-imports}} +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}): """ @@ -113,7 +118,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> {{^hasChildren}}{{{classname}}}{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union({{#children}}{{{classname}}}{{^-last}}, {{/-last}}{{/children}}){{/discriminator}}{{^discriminator}}{{{classname}}}{{/discriminator}}{{/hasChildren}}: + def from_json(cls, json_str: str) -> {{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}: """Create an instance of {{{classname}}} from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -215,7 +220,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return _dict @classmethod - def from_dict(cls, obj: dict) -> {{^hasChildren}}{{{classname}}}{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union({{#children}}{{{classname}}}{{^-last}}, {{/-last}}{{/children}}){{/discriminator}}{{^discriminator}}{{{classname}}}{{/discriminator}}{{/hasChildren}}: + def from_dict(cls, obj: dict) -> {{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}: """Create an instance of {{{classname}}} from a dict""" {{#hasChildren}} {{#discriminator}} @@ -235,7 +240,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return None if not isinstance(obj, dict): - return {{{classname}}}.model_validate(obj) + return cls.model_validate(obj) {{#disallowAdditionalPropertiesIfNotPresent}} {{^isAdditionalPropertiesTrue}} @@ -246,7 +251,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isAdditionalPropertiesTrue}} {{/disallowAdditionalPropertiesIfNotPresent}} - _obj = {{{classname}}}.model_validate({ + _obj = cls.model_validate({ {{#allVars}} {{#isContainer}} {{#isArray}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 83b15304bd50..36c46e5c4f2b 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -15,6 +15,10 @@ import re # noqa: F401 from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] @@ -97,13 +101,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v @classmethod - def from_dict(cls, obj: dict) -> {{{classname}}}: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> {{{classname}}}: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = {{{classname}}}.model_construct() + instance = cls.model_construct() {{#isNullable}} if json_str is None: return instance diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py index 4e7959696e72..52ec94980e97 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from openapi_client.api_client import ApiClient @@ -130,18 +131,18 @@ def test_auth_http_basic_with_http_info(self, **kwargs) -> ApiResponse: # noqa: _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -149,9 +150,9 @@ def test_auth_http_basic_with_http_info(self, **kwargs) -> ApiResponse: # noqa: ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = ['http_auth'] # noqa: E501 + _auth_settings: List[str] = ['http_auth'] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py index e3465a71db4c..ee35d4c26742 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from pydantic import Field from typing_extensions import Annotated @@ -138,18 +139,18 @@ def test_binary_gif_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -157,9 +158,9 @@ def test_binary_gif_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 ['image/gif']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "bytearray", } @@ -275,18 +276,18 @@ def test_body_application_octetstream_binary_with_http_info(self, body : Optiona _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None if _params['body'] is not None: @@ -309,9 +310,9 @@ def test_body_application_octetstream_binary_with_http_info(self, body : Optiona _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -427,18 +428,18 @@ def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : Li _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} if _params['files'] is not None: _files['files'] = _params['files'] _collection_formats['files'] = 'csv' @@ -457,9 +458,9 @@ def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : Li _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -575,18 +576,18 @@ def test_echo_body_free_form_object_response_string_with_http_info(self, body : _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None if _params['body'] is not None: @@ -604,9 +605,9 @@ def test_echo_body_free_form_object_response_string_with_http_info(self, body : _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -722,18 +723,18 @@ def test_echo_body_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None if _params['pet'] is not None: @@ -751,9 +752,9 @@ def test_echo_body_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", } @@ -869,18 +870,18 @@ def test_echo_body_pet_response_string_with_http_info(self, pet : Annotated[Opti _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None if _params['pet'] is not None: @@ -898,9 +899,9 @@ def test_echo_body_pet_response_string_with_http_info(self, pet : Annotated[Opti _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -1016,18 +1017,18 @@ def test_echo_body_tag_response_string_with_http_info(self, tag : Annotated[Opti _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None if _params['tag'] is not None: @@ -1045,9 +1046,9 @@ def test_echo_body_tag_response_string_with_http_info(self, tag : Annotated[Opti _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py index 7d92389ace76..9c24a5feebde 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from pydantic import StrictBool, StrictInt, StrictStr @@ -149,18 +150,18 @@ def test_form_integer_boolean_string_with_http_info(self, integer_form : Optiona _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} if _params['integer_form'] is not None: _form_params.append(('integer_form', _params['integer_form'])) @@ -184,9 +185,9 @@ def test_form_integer_boolean_string_with_http_info(self, integer_form : Optiona _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -327,18 +328,18 @@ def test_form_oneof_with_http_info(self, form1 : Optional[StrictStr] = None, for _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} if _params['form1'] is not None: _form_params.append(('form1', _params['form1'])) @@ -371,9 +372,9 @@ def test_form_oneof_with_http_info(self, form1 : Optional[StrictStr] = None, for _header_params['Content-Type'] = _content_types_list # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py index 5a1bef8ba30b..68a9063e576b 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from pydantic import StrictBool, StrictInt, StrictStr @@ -149,13 +150,13 @@ def test_header_integer_boolean_string_with_http_info(self, integer_header : Opt _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) if _params['integer_header'] is not None: @@ -168,8 +169,8 @@ def test_header_integer_boolean_string_with_http_info(self, integer_header : Opt _header_params['string_header'] = _params['string_header'] # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -177,9 +178,9 @@ def test_header_integer_boolean_string_with_http_info(self, integer_header : Opt ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py index 99f144742ab1..8e873c3e34c6 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from pydantic import StrictInt, StrictStr @@ -142,10 +143,10 @@ def tests_path_string_path_string_integer_path_integer_with_http_info(self, path _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} if _params['path_string'] is not None: _path_params['path_string'] = _params['path_string'] @@ -154,12 +155,12 @@ def tests_path_string_path_string_integer_path_integer_with_http_info(self, path # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -167,9 +168,9 @@ def tests_path_string_path_string_integer_path_integer_with_http_info(self, path ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py index caca1968b164..741f0f7a81d2 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py @@ -18,6 +18,7 @@ import warnings from pydantic import validate_call, ValidationError +from typing import Dict, List, Optional, Tuple from datetime import date, datetime @@ -144,21 +145,21 @@ def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[S _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('enum_ref_string_query') is not None: # noqa: E501 _query_params.append(('enum_ref_string_query', _params['enum_ref_string_query'].value)) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -166,9 +167,9 @@ def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[S ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -294,13 +295,13 @@ def test_query_datetime_date_string_with_http_info(self, datetime_query : Option _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('datetime_query') is not None: # noqa: E501 if isinstance(_params['datetime_query'], datetime): _query_params.append(('datetime_query', _params['datetime_query'].strftime(self.api_client.configuration.datetime_format))) @@ -319,8 +320,8 @@ def test_query_datetime_date_string_with_http_info(self, datetime_query : Option # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -328,9 +329,9 @@ def test_query_datetime_date_string_with_http_info(self, datetime_query : Option ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -456,13 +457,13 @@ def test_query_integer_boolean_string_with_http_info(self, integer_query : Optio _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('integer_query') is not None: # noqa: E501 _query_params.append(('integer_query', _params['integer_query'])) @@ -475,8 +476,8 @@ def test_query_integer_boolean_string_with_http_info(self, integer_query : Optio # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -484,9 +485,9 @@ def test_query_integer_boolean_string_with_http_info(self, integer_query : Optio ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -602,21 +603,21 @@ def test_query_style_deep_object_explode_true_object_with_http_info(self, query_ _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('query_object') is not None: # noqa: E501 _query_params.append(('query_object', _params['query_object'])) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -624,9 +625,9 @@ def test_query_style_deep_object_explode_true_object_with_http_info(self, query_ ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -742,21 +743,21 @@ def test_query_style_deep_object_explode_true_object_all_of_with_http_info(self, _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('query_object') is not None: # noqa: E501 _query_params.append(('query_object', _params['query_object'])) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -764,9 +765,9 @@ def test_query_style_deep_object_explode_true_object_all_of_with_http_info(self, ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -882,21 +883,21 @@ def test_query_style_form_explode_true_array_string_with_http_info(self, query_o _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('query_object') is not None: # noqa: E501 _query_params.append(('query_object', _params['query_object'])) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -904,9 +905,9 @@ def test_query_style_form_explode_true_array_string_with_http_info(self, query_o ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -1022,21 +1023,21 @@ def test_query_style_form_explode_true_object_with_http_info(self, query_object _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('query_object') is not None: # noqa: E501 _query_params.append(('query_object', _params['query_object'])) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -1044,9 +1045,9 @@ def test_query_style_form_explode_true_object_with_http_info(self, query_object ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } @@ -1162,21 +1163,21 @@ def test_query_style_form_explode_true_object_all_of_with_http_info(self, query_ _params[_key] = _val del _params['kwargs'] - _collection_formats = {} + _collection_formats: Dict[str, str] = {} # process the path parameters - _path_params = {} + _path_params: Dict[str, str] = {} # process the query parameters - _query_params = [] + _query_params: List[Tuple[str, str]] = [] if _params.get('query_object') is not None: # noqa: E501 _query_params.append(('query_object', _params['query_object'])) # process the header parameters _header_params = dict(_params.get('_headers', {})) # process the form parameters - _form_params = [] - _files = {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} # process the body parameter _body_params = None # set the HTTP header `Accept` @@ -1184,9 +1185,9 @@ def test_query_style_form_explode_true_object_all_of_with_http_info(self, query_ ['text/plain']) # noqa: E501 # authentication setting - _auth_settings = [] # noqa: E501 + _auth_settings: List[str] = [] # noqa: E501 - _response_types_map = { + _response_types_map: Dict[str, Optional[str]] = { '200': "str", } diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py index 8906f9831440..d0ab19e99d4c 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Bird(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Bird: + def from_json(cls, json_str: str) -> Self: """Create an instance of Bird from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,20 +64,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Bird: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Bird from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Bird.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in Bird) in the input: " + _key) - _obj = Bird.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "color": obj.get("color") }) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py index 43202dea0f22..20b356fbbe58 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Category(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Category: + def from_json(cls, json_str: str) -> Self: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,20 +64,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Category: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Category from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Category.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in Category) in the input: " + _key) - _obj = Category.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py index 8ee7d09e92f3..5109804e23c6 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py @@ -23,6 +23,11 @@ from pydantic import StrictStr from pydantic import Field from openapi_client.models.query import Query +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DataQuery(Query): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DataQuery: + def from_json(cls, json_str: str) -> Self: """Create an instance of DataQuery from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,20 +67,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DataQuery: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DataQuery from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DataQuery.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in DataQuery) in the input: " + _key) - _obj = DataQuery.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "outcomes": obj.get("outcomes"), "suffix": obj.get("suffix"), diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py index bb8a2ccd9633..0ee39cd7da48 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py @@ -22,6 +22,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictInt, StrictStr, field_validator from openapi_client.models.string_enum_ref import StringEnumRef +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DefaultValue(BaseModel): """ @@ -64,7 +69,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of DefaultValue from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -92,20 +97,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DefaultValue: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DefaultValue from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DefaultValue.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in DefaultValue) in the input: " + _key) - _obj = DefaultValue.model_validate({ + _obj = cls.model_validate({ "array_string_enum_ref_default": obj.get("array_string_enum_ref_default"), "array_string_enum_default": obj.get("array_string_enum_default"), "array_string_default": obj.get("array_string_default"), diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py index dd83b12cea2d..c3b9d07f3359 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py @@ -23,6 +23,11 @@ from pydantic import BaseModel, StrictFloat, StrictInt from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NumberPropertiesOnly(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NumberPropertiesOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of NumberPropertiesOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,20 +67,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NumberPropertiesOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NumberPropertiesOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NumberPropertiesOnly.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in NumberPropertiesOnly) in the input: " + _key) - _obj = NumberPropertiesOnly.model_validate({ + _obj = cls.model_validate({ "number": obj.get("number"), "float": obj.get("float"), "double": obj.get("double") diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py index 232a7d618285..764f2a4fe456 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py @@ -24,6 +24,11 @@ from pydantic import Field from openapi_client.models.category import Category from openapi_client.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Pet(BaseModel): """ @@ -63,7 +68,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Pet: + def from_json(cls, json_str: str) -> Self: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -86,20 +91,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Pet: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Pet from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Pet.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in Pet) in the input: " + _key) - _obj = Pet.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name"), "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py index 0821271f8293..249c7ef9305d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py @@ -22,6 +22,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Query(BaseModel): """ @@ -58,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Query: + def from_json(cls, json_str: str) -> Self: """Create an instance of Query from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -71,7 +76,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Query: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/string_enum_ref.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/string_enum_ref.py index f200a1dafb8e..cedd6194f983 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/string_enum_ref.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/string_enum_ref.py @@ -13,13 +13,18 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum +try: + from typing import Self +except ImportError: + from typing_extensions import Self class StringEnumRef(str, Enum): @@ -35,8 +40,8 @@ class StringEnumRef(str, Enum): UNCLASSIFIED = 'unclassified' @classmethod - def from_json(cls, json_str: str) -> StringEnumRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of StringEnumRef from a JSON string""" - return StringEnumRef(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py index 20b098a4269f..6a82d3e78b70 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tag(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tag: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,20 +64,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tag: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tag from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tag.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in Tag) in the input: " + _key) - _obj = Tag.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 28380a635d35..1805760ee9c2 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,20 +66,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter) in the input: " + _key) - _obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "color": obj.get("color"), "id": obj.get("id"), diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 221e15cfb147..1eb4fce15157 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,20 +63,20 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate(obj) + return cls.model_validate(obj) # raise errors for additional fields in the input for _key in obj.keys(): if _key not in cls.__properties: raise ValueError("Error due to additional fields (not defined in TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter) in the input: " + _key) - _obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate({ + _obj = cls.model_validate({ "values": obj.get("values") }) return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml index c79828a122d1..af471ab63148 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml @@ -15,7 +15,6 @@ python = "^3.7" urllib3 = ">= 1.25.3" python-dateutil = ">=2.8.2" pydantic = ">=2" -aenum = ">=3.1.11" typing-extensions = ">=4.7.1" [tool.poetry.dev-dependencies] diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/requirements.txt b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/requirements.txt index 4407c81fb743..cc85509ec516 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/requirements.txt +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/requirements.txt @@ -2,5 +2,4 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 pydantic >= 2 -aenum >= 3.1.11 typing-extensions >= 4.7.1 diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/setup.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/setup.py index 54a88267fb4a..82528555eef1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/setup.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/setup.py @@ -28,7 +28,6 @@ "urllib3 >= 1.25.3, < 2.1.0", "python-dateutil", "pydantic >= 2", - "aenum", "typing-extensions >= 4.7.1", ] diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 4faec5101c67..f50597d0f717 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Bird(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Bird: + def from_json(cls, json_str: str) -> Self: """Create an instance of Bird from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Bird: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Bird from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Bird.model_validate(obj) + return cls.model_validate(obj) - _obj = Bird.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "color": obj.get("color") }) diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index 29a4d21d402d..0c7eeb936286 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Category(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Category: + def from_json(cls, json_str: str) -> Self: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Category: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Category from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Category.model_validate(obj) + return cls.model_validate(obj) - _obj = Category.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index a6d7de7745a9..37e903f0a4d6 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -23,6 +23,11 @@ from pydantic import StrictStr from pydantic import Field from openapi_client.models.query import Query +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DataQuery(Query): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DataQuery: + def from_json(cls, json_str: str) -> Self: """Create an instance of DataQuery from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,15 +67,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DataQuery: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DataQuery from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DataQuery.model_validate(obj) + return cls.model_validate(obj) - _obj = DataQuery.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "outcomes": obj.get("outcomes"), "suffix": obj.get("suffix"), diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 7e64618e73db..0cdf153661b2 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -22,6 +22,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictInt, StrictStr, field_validator from openapi_client.models.string_enum_ref import StringEnumRef +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DefaultValue(BaseModel): """ @@ -64,7 +69,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of DefaultValue from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -92,15 +97,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DefaultValue: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DefaultValue from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DefaultValue.model_validate(obj) + return cls.model_validate(obj) - _obj = DefaultValue.model_validate({ + _obj = cls.model_validate({ "array_string_enum_ref_default": obj.get("array_string_enum_ref_default"), "array_string_enum_default": obj.get("array_string_enum_default"), "array_string_default": obj.get("array_string_default"), diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 0720150c100a..c45a00b4a5f0 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -23,6 +23,11 @@ from pydantic import BaseModel, StrictFloat, StrictInt from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NumberPropertiesOnly(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NumberPropertiesOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of NumberPropertiesOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,15 +67,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NumberPropertiesOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NumberPropertiesOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NumberPropertiesOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = NumberPropertiesOnly.model_validate({ + _obj = cls.model_validate({ "number": obj.get("number"), "float": obj.get("float"), "double": obj.get("double") 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 b5d2120454d8..cbb72e9aedd4 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -24,6 +24,11 @@ from pydantic import Field from openapi_client.models.category import Category from openapi_client.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Pet(BaseModel): """ @@ -63,7 +68,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Pet: + def from_json(cls, json_str: str) -> Self: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -86,15 +91,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Pet: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Pet from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Pet.model_validate(obj) + return cls.model_validate(obj) - _obj = Pet.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name"), "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 0821271f8293..249c7ef9305d 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -22,6 +22,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Query(BaseModel): """ @@ -58,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Query: + def from_json(cls, json_str: str) -> Self: """Create an instance of Query from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -71,7 +76,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Query: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py b/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py index 18bef6e7efa5..cedd6194f983 100644 --- a/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py +++ b/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py @@ -21,6 +21,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class StringEnumRef(str, Enum): @@ -36,8 +40,8 @@ class StringEnumRef(str, Enum): UNCLASSIFIED = 'unclassified' @classmethod - def from_json(cls, json_str: str) -> StringEnumRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of StringEnumRef from a JSON string""" - return StringEnumRef(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index adc2b1e2e96a..a6bc09cbfe16 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tag(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tag: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tag: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tag from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tag.model_validate(obj) + return cls.model_validate(obj) - _obj = Tag.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 2938541cf150..5bba5af567ba 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate(obj) + return cls.model_validate(obj) - _obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "color": obj.get("color"), "id": obj.get("id"), diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index c750437aa526..04452777e1ec 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate(obj) + return cls.model_validate(obj) - _obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate({ + _obj = cls.model_validate({ "values": obj.get("values") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index fdb014a11857..a75e27dc6cac 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesAnyType(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesAnyType from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesAnyType from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesAnyType.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesAnyType.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties 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 1dd4ecafa718..ef538719c649 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 @@ -20,6 +20,11 @@ from typing import Dict, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesClass(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesClass.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesClass.model_validate({ + _obj = cls.model_validate({ "map_property": obj.get("map_property"), "map_of_map_property": obj.get("map_of_map_property") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index 44094e7ba1bd..0a08d54a3218 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesObject(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesObject: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesObject: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesObject from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesObject.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesObject.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 5fc0bd189e2c..b293f268deb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesWithDescriptionOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesWithDescriptionOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesWithDescriptionOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesWithDescriptionOnly.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index d8205750a13f..95b2ca73be95 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field from petstore_api.models.single_ref_type import SingleRefType +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AllOfWithSingleRef(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AllOfWithSingleRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of AllOfWithSingleRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -60,15 +65,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AllOfWithSingleRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AllOfWithSingleRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AllOfWithSingleRef.model_validate(obj) + return cls.model_validate(obj) - _obj = AllOfWithSingleRef.model_validate({ + _obj = cls.model_validate({ "username": obj.get("username"), "SingleRefType": obj.get("SingleRefType") }) 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 b5fc122a115a..9d6fac114377 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 @@ -21,6 +21,11 @@ from typing import Optional, Union from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Animal(BaseModel): """ @@ -63,7 +68,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union(Cat, Dog): + def from_json(cls, json_str: str) -> Union[Self, Self]: """Create an instance of Animal from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -76,7 +81,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Union(Cat, Dog): + def from_dict(cls, obj: dict) -> Union[Self, Self]: """Create an instance of Animal from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index 23097a497506..db4718b868b0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -88,13 +92,13 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> AnyOfColor: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> AnyOfColor: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = AnyOfColor.model_construct() + instance = cls.model_construct() error_messages = [] # deserialize data into List[int] try: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index 00369b878bd3..2a2a04932225 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -80,13 +84,13 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> AnyOfPig: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> AnyOfPig: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = AnyOfPig.model_construct() + instance = cls.model_construct() error_messages = [] # anyof_schema_1_validator: Optional[BasquePig] = None try: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py index ff52eb711941..62a2a6a35495 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ApiResponse(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ApiResponse: + def from_json(cls, json_str: str) -> Self: """Create an instance of ApiResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ApiResponse: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ApiResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ApiResponse.model_validate(obj) + return cls.model_validate(obj) - _obj = ApiResponse.model_validate({ + _obj = cls.model_validate({ "code": obj.get("code"), "type": obj.get("type"), "message": obj.get("message") 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 c6ef3f968c73..351c2e0193ed 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 @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfArrayOfModel(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfArrayOfModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,15 +72,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfArrayOfModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfArrayOfModel.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfArrayOfModel.model_validate({ + _obj = cls.model_validate({ "another_property": [ [Tag.from_dict(_inner_item) for _inner_item in _item] for _item in obj.get("another_property") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index b9f51b6588d2..5f047262eeb7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfArrayOfNumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfArrayOfNumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfArrayOfNumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfArrayOfNumberOnly.model_validate({ + _obj = cls.model_validate({ "ArrayArrayNumber": obj.get("ArrayArrayNumber") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 909e276ba41c..eaa029c77889 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfNumberOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfNumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfNumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfNumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfNumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfNumberOnly.model_validate({ + _obj = cls.model_validate({ "ArrayNumber": obj.get("ArrayNumber") }) return _obj 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 347e6c326cf4..2b2698a90e43 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 @@ -23,6 +23,11 @@ from pydantic import Field from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayTest(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -71,15 +76,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayTest.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayTest.model_validate({ + _obj = cls.model_validate({ "array_of_string": obj.get("array_of_string"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index b1466ef6ba6d..847502d2f30f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -21,6 +21,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class BasquePig(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> BasquePig: + def from_json(cls, json_str: str) -> Self: """Create an instance of BasquePig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> BasquePig: + def from_dict(cls, obj: dict) -> Self: """Create an instance of BasquePig from a dict""" if obj is None: return None if not isinstance(obj, dict): - return BasquePig.model_validate(obj) + return cls.model_validate(obj) - _obj = BasquePig.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 3df7fd7a355f..e15951c517c7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Capitalization(BaseModel): """ @@ -50,7 +55,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Capitalization: + def from_json(cls, json_str: str) -> Self: """Create an instance of Capitalization from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,15 +68,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Capitalization: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Capitalization from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Capitalization.model_validate(obj) + return cls.model_validate(obj) - _obj = Capitalization.model_validate({ + _obj = cls.model_validate({ "smallCamel": obj.get("smallCamel"), "CapitalCamel": obj.get("CapitalCamel"), "small_Snake": obj.get("small_Snake"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 4eb15fe66391..4a78ee14dfdf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import StrictBool from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Cat(Animal): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Cat: + def from_json(cls, json_str: str) -> Self: """Create an instance of Cat from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Cat: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Cat from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Cat.model_validate(obj) + return cls.model_validate(obj) - _obj = Cat.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") if obj.get("color") is not None else 'red', "declawed": obj.get("declawed") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index 85980ccbfcbe..d82e08a5fba8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Category(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Category: + def from_json(cls, json_str: str) -> Self: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Category: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Category from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Category.model_validate(obj) + return cls.model_validate(obj) - _obj = Category.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") if obj.get("name") is not None else 'default-name' }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 8f990f6af2d9..7a2ef55fd84c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class CircularReferenceModel(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> CircularReferenceModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of CircularReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> CircularReferenceModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of CircularReferenceModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CircularReferenceModel.model_validate(obj) + return cls.model_validate(obj) - _obj = CircularReferenceModel.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 081c56687fd0..8ced8f6ae320 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ClassModel(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ClassModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of ClassModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ClassModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ClassModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ClassModel.model_validate(obj) + return cls.model_validate(obj) - _obj = ClassModel.model_validate({ + _obj = cls.model_validate({ "_class": obj.get("_class") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 22bdd59b4c65..8f3b2500c9f0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Client(BaseModel): """ @@ -44,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Client: + def from_json(cls, json_str: str) -> Self: """Create an instance of Client from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -57,15 +62,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Client: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Client from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Client.model_validate(obj) + return cls.model_validate(obj) - _obj = Client.model_validate({ + _obj = cls.model_validate({ "client": obj.get("client") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index 2fdc7e8805cf..b5abaccbd0ba 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -92,13 +96,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> Color: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> Color: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = Color.model_construct() + instance = cls.model_construct() if json_str is None: return instance 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 cf89e2dd47cc..4987551a2a19 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 @@ -21,6 +21,11 @@ from pydantic import BaseModel, StrictStr from petstore_api.models.creature_info import CreatureInfo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Creature(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Creature: + def from_json(cls, json_str: str) -> Self: """Create an instance of Creature from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,15 +67,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Creature: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Creature from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Creature.model_validate(obj) + return cls.model_validate(obj) - _obj = Creature.model_validate({ + _obj = cls.model_validate({ "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, "type": obj.get("type") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 95a21ace904e..705cb0966295 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -20,6 +20,11 @@ from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class CreatureInfo(BaseModel): """ @@ -44,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> CreatureInfo: + def from_json(cls, json_str: str) -> Self: """Create an instance of CreatureInfo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -57,15 +62,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> CreatureInfo: + def from_dict(cls, obj: dict) -> Self: """Create an instance of CreatureInfo from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CreatureInfo.model_validate(obj) + return cls.model_validate(obj) - _obj = CreatureInfo.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index 3a51136fb920..bed6adfb8204 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -21,6 +21,11 @@ from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DanishPig(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DanishPig: + def from_json(cls, json_str: str) -> Self: """Create an instance of DanishPig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DanishPig: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DanishPig from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DanishPig.model_validate(obj) + return cls.model_validate(obj) - _obj = DanishPig.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "size": obj.get("size") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index a3cef015f531..65a37cfec5e3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DeprecatedObject(BaseModel): """ @@ -44,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DeprecatedObject: + def from_json(cls, json_str: str) -> Self: """Create an instance of DeprecatedObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -57,15 +62,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DeprecatedObject: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DeprecatedObject from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DeprecatedObject.model_validate(obj) + return cls.model_validate(obj) - _obj = DeprecatedObject.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index 42407d8c8da7..e867e1a86175 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import StrictStr from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Dog(Animal): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Dog: + def from_json(cls, json_str: str) -> Self: """Create an instance of Dog from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Dog: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Dog from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Dog.model_validate(obj) + return cls.model_validate(obj) - _obj = Dog.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") if obj.get("color") is not None else 'red', "breed": obj.get("breed") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index d4115fac5668..475a8b2e7777 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DummyModel(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DummyModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of DummyModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DummyModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DummyModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DummyModel.model_validate(obj) + return cls.model_validate(obj) - _obj = DummyModel.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index d16aeba5c4e8..1c05962bf132 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -20,6 +20,11 @@ from typing import List, Optional from pydantic import BaseModel, StrictStr, field_validator +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumArrays(BaseModel): """ @@ -66,7 +71,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> EnumArrays: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumArrays from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -79,15 +84,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> EnumArrays: + def from_dict(cls, obj: dict) -> Self: """Create an instance of EnumArrays from a dict""" if obj is None: return None if not isinstance(obj, dict): - return EnumArrays.model_validate(obj) + return cls.model_validate(obj) - _obj = EnumArrays.model_validate({ + _obj = cls.model_validate({ "just_symbol": obj.get("just_symbol"), "array_enum": obj.get("array_enum") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py index b7d443776def..11255f418979 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumClass(str, Enum): @@ -35,8 +39,8 @@ class EnumClass(str, Enum): LEFT_PARENTHESIS_XYZ_RIGHT_PARENTHESIS = '(xyz)' @classmethod - def from_json(cls, json_str: str) -> EnumClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumClass from a JSON string""" - return EnumClass(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py index 71f9f0c10c15..efe9a6056218 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString1(str, Enum): @@ -34,8 +38,8 @@ class EnumString1(str, Enum): B = 'b' @classmethod - def from_json(cls, json_str: str) -> EnumString1: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString1 from a JSON string""" - return EnumString1(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py index 2cba894b5d79..222c5dc6b824 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString2(str, Enum): @@ -34,8 +38,8 @@ class EnumString2(str, Enum): D = 'd' @classmethod - def from_json(cls, json_str: str) -> EnumString2: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString2 from a JSON string""" - return EnumString2(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index c10be465fc68..11ed262bef20 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -25,6 +25,11 @@ from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumTest(BaseModel): """ @@ -104,7 +109,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> EnumTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -122,15 +127,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> EnumTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of EnumTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return EnumTest.model_validate(obj) + return cls.model_validate(obj) - _obj = EnumTest.model_validate({ + _obj = cls.model_validate({ "enum_string": obj.get("enum_string"), "enum_string_required": obj.get("enum_string_required"), "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 259c9b287ddf..82699961a307 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class File(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> File: + def from_json(cls, json_str: str) -> Self: """Create an instance of File from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> File: + def from_dict(cls, obj: dict) -> Self: """Create an instance of File from a dict""" if obj is None: return None if not isinstance(obj, dict): - return File.model_validate(obj) + return cls.model_validate(obj) - _obj = File.model_validate({ + _obj = cls.model_validate({ "sourceURI": obj.get("sourceURI") }) return _obj 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 1fdd13db0e9f..cc10781e57b5 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 @@ -21,6 +21,11 @@ from typing import List, Optional from pydantic import BaseModel from petstore_api.models.file import File +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FileSchemaTestClass(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FileSchemaTestClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of FileSchemaTestClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -69,15 +74,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FileSchemaTestClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FileSchemaTestClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FileSchemaTestClass.model_validate(obj) + return cls.model_validate(obj) - _obj = FileSchemaTestClass.model_validate({ + _obj = cls.model_validate({ "file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None, "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index 821e0345fb02..4e2df11213b3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FirstRef(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FirstRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of FirstRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FirstRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FirstRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FirstRef.model_validate(obj) + return cls.model_validate(obj) - _obj = FirstRef.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index ac5001690157..f5195ee6132f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Foo(BaseModel): """ @@ -44,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Foo: + def from_json(cls, json_str: str) -> Self: """Create an instance of Foo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -57,15 +62,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Foo: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Foo from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Foo.model_validate(obj) + return cls.model_validate(obj) - _obj = Foo.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index 69025e9dca84..74e01a73cee4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel from petstore_api.models.foo import Foo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FooGetDefaultResponse(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FooGetDefaultResponse: + def from_json(cls, json_str: str) -> Self: """Create an instance of FooGetDefaultResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FooGetDefaultResponse: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FooGetDefaultResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FooGetDefaultResponse.model_validate(obj) + return cls.model_validate(obj) - _obj = FooGetDefaultResponse.model_validate({ + _obj = cls.model_validate({ "string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index 3f34bfd6570d..ee085fda78b4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -23,6 +23,11 @@ from decimal import Decimal from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FormatTest(BaseModel): """ @@ -103,7 +108,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FormatTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of FormatTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -116,15 +121,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FormatTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FormatTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FormatTest.model_validate(obj) + return cls.model_validate(obj) - _obj = FormatTest.model_validate({ + _obj = cls.model_validate({ "integer": obj.get("integer"), "int32": obj.get("int32"), "int64": obj.get("int64"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index 232f4561d39b..1749a4c35aa9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class HasOnlyReadOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> HasOnlyReadOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of HasOnlyReadOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -60,15 +65,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> HasOnlyReadOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of HasOnlyReadOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return HasOnlyReadOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = HasOnlyReadOnly.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar"), "foo": obj.get("foo") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index 162bcbbe33ef..e4b2875cbaca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class HealthCheckResult(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> HealthCheckResult: + def from_json(cls, json_str: str) -> Self: """Create an instance of HealthCheckResult from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,15 +68,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> HealthCheckResult: + def from_dict(cls, obj: dict) -> Self: """Create an instance of HealthCheckResult from a dict""" if obj is None: return None if not isinstance(obj, dict): - return HealthCheckResult.model_validate(obj) + return cls.model_validate(obj) - _obj = HealthCheckResult.model_validate({ + _obj = cls.model_validate({ "NullableMessage": obj.get("NullableMessage") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index eb660f836533..91b6b72c2ce0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -21,6 +21,11 @@ from typing import Any, Dict, Optional, Union from pydantic import BaseModel from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class InnerDictWithProperty(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> InnerDictWithProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of InnerDictWithProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> InnerDictWithProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of InnerDictWithProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return InnerDictWithProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = InnerDictWithProperty.model_validate({ + _obj = cls.model_validate({ "aProperty": obj.get("aProperty") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index 0fb43ecaebb3..cd6f56fdeba5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -81,13 +85,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> IntOrString: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> IntOrString: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = IntOrString.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py index be0719de484a..e1a3d53f6d5d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class List(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> List: + def from_json(cls, json_str: str) -> Self: """Create an instance of List from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> List: + def from_dict(cls, obj: dict) -> Self: """Create an instance of List from a dict""" if obj is None: return None if not isinstance(obj, dict): - return List.model_validate(obj) + return cls.model_validate(obj) - _obj = List.model_validate({ + _obj = cls.model_validate({ "123-list": obj.get("123-list") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index 8bbdc3ea394a..5ce38a185f97 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ListClass(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ListClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of ListClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ListClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ListClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ListClass.model_validate(obj) + return cls.model_validate(obj) - _obj = ListClass.model_validate({ + _obj = cls.model_validate({ "123-list": obj.get("123-list") }) return _obj 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 c6f51733b319..ace4427534c5 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MapOfArrayOfModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MapOfArrayOfModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of MapOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MapOfArrayOfModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MapOfArrayOfModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MapOfArrayOfModel.model_validate(obj) + return cls.model_validate(obj) - _obj = MapOfArrayOfModel.model_validate({ + _obj = cls.model_validate({ "shopIdToOrgOnlineLipMap": dict( (_k, [Tag.from_dict(_item) for _item in _v] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 0f48db387b8b..d2d550fa3927 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -20,6 +20,11 @@ from typing import Dict, Optional from pydantic import BaseModel, StrictBool, StrictStr, field_validator +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MapTest(BaseModel): """ @@ -57,7 +62,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MapTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of MapTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -70,15 +75,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MapTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MapTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MapTest.model_validate(obj) + return cls.model_validate(obj) - _obj = MapTest.model_validate({ + _obj = cls.model_validate({ "map_map_of_string": obj.get("map_map_of_string"), "map_of_enum_string": obj.get("map_of_enum_string"), "direct_map": obj.get("direct_map"), 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 e87f188c76d2..801b8a52b914 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MixedPropertiesAndAdditionalPropertiesClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MixedPropertiesAndAdditionalPropertiesClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MixedPropertiesAndAdditionalPropertiesClass.model_validate(obj) + return cls.model_validate(obj) - _obj = MixedPropertiesAndAdditionalPropertiesClass.model_validate({ + _obj = cls.model_validate({ "uuid": obj.get("uuid"), "dateTime": obj.get("dateTime"), "map": dict( diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index ca9ccecf54b9..8e8d59385728 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Model200Response(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Model200Response: + def from_json(cls, json_str: str) -> Self: """Create an instance of Model200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Model200Response: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Model200Response from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Model200Response.model_validate(obj) + return cls.model_validate(obj) - _obj = Model200Response.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name"), "class": obj.get("class") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index c6c9aba0e5f6..83fc91b028b3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ModelReturn(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ModelReturn: + def from_json(cls, json_str: str) -> Self: """Create an instance of ModelReturn from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ModelReturn: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ModelReturn from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ModelReturn.model_validate(obj) + return cls.model_validate(obj) - _obj = ModelReturn.model_validate({ + _obj = cls.model_validate({ "return": obj.get("return") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index f10a28e45649..53f2da64c6c2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Name(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Name: + def from_json(cls, json_str: str) -> Self: """Create an instance of Name from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,15 +68,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Name: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Name from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Name.model_validate(obj) + return cls.model_validate(obj) - _obj = Name.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name"), "snake_case": obj.get("snake_case"), "property": obj.get("property"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index 3846d628b7d0..29229982ee63 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -20,6 +20,11 @@ from datetime import date, datetime from typing import Any, Dict, List, Optional, Union from pydantic import BaseModel, StrictBool, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NullableClass(BaseModel): """ @@ -57,7 +62,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NullableClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of NullableClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -131,15 +136,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NullableClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NullableClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NullableClass.model_validate(obj) + return cls.model_validate(obj) - _obj = NullableClass.model_validate({ + _obj = cls.model_validate({ "required_integer_prop": obj.get("required_integer_prop"), "integer_prop": obj.get("integer_prop"), "number_prop": obj.get("number_prop"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 21d8affe0975..9dd3d14508a4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt, field_validator from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NullableProperty(BaseModel): """ @@ -57,7 +62,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NullableProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of NullableProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,15 +80,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NullableProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NullableProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NullableProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = NullableProperty.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index a276048ee175..673d22790a10 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NumberOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of NumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = NumberOnly.model_validate({ + _obj = cls.model_validate({ "JustNumber": obj.get("JustNumber") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 1d4ee37cac68..dfdf124a7655 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictBool from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ObjectToTestAdditionalProperties(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ObjectToTestAdditionalProperties: + def from_json(cls, json_str: str) -> Self: """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ObjectToTestAdditionalProperties: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ObjectToTestAdditionalProperties from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ObjectToTestAdditionalProperties.model_validate(obj) + return cls.model_validate(obj) - _obj = ObjectToTestAdditionalProperties.model_validate({ + _obj = cls.model_validate({ "property": obj.get("property") if obj.get("property") is not None else False }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index 378af096758d..b40e899696c0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field from petstore_api.models.deprecated_object import DeprecatedObject +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ObjectWithDeprecatedFields(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ObjectWithDeprecatedFields: + def from_json(cls, json_str: str) -> Self: """Create an instance of ObjectWithDeprecatedFields from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ObjectWithDeprecatedFields: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ObjectWithDeprecatedFields from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ObjectWithDeprecatedFields.model_validate(obj) + return cls.model_validate(obj) - _obj = ObjectWithDeprecatedFields.model_validate({ + _obj = cls.model_validate({ "uuid": obj.get("uuid"), "id": obj.get("id"), "deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py index 65067fe7620e..3e9c111a4a73 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -79,13 +83,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> OneOfEnumString: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> OneOfEnumString: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = OneOfEnumString.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index b2fc224da788..a6d9cc667bc2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, field_validator from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Order(BaseModel): """ @@ -60,7 +65,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Order: + def from_json(cls, json_str: str) -> Self: """Create an instance of Order from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -73,15 +78,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Order: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Order from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Order.model_validate(obj) + return cls.model_validate(obj) - _obj = Order.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "petId": obj.get("petId"), "quantity": obj.get("quantity"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index 031513b9f786..895cb42f2f89 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictBool, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterComposite(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> OuterComposite: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterComposite from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> OuterComposite: + def from_dict(cls, obj: dict) -> Self: """Create an instance of OuterComposite from a dict""" if obj is None: return None if not isinstance(obj, dict): - return OuterComposite.model_validate(obj) + return cls.model_validate(obj) - _obj = OuterComposite.model_validate({ + _obj = cls.model_validate({ "my_number": obj.get("my_number"), "my_string": obj.get("my_string"), "my_boolean": obj.get("my_boolean") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py index eaed7b602149..89b19cbcf664 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnum(str, Enum): @@ -35,8 +39,8 @@ class OuterEnum(str, Enum): DELIVERED = 'delivered' @classmethod - def from_json(cls, json_str: str) -> OuterEnum: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnum from a JSON string""" - return OuterEnum(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py index 6d3bc533869b..51ca91443e27 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumDefaultValue(str, Enum): @@ -35,8 +39,8 @@ class OuterEnumDefaultValue(str, Enum): DELIVERED = 'delivered' @classmethod - def from_json(cls, json_str: str) -> OuterEnumDefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumDefaultValue from a JSON string""" - return OuterEnumDefaultValue(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py index 0c885e23b9cf..8947df650469 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumInteger(int, Enum): @@ -35,8 +39,8 @@ class OuterEnumInteger(int, Enum): NUMBER_2 = 2 @classmethod - def from_json(cls, json_str: str) -> OuterEnumInteger: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumInteger from a JSON string""" - return OuterEnumInteger(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py index 99ca40483d6a..970487bb0c4d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumIntegerDefaultValue(int, Enum): @@ -36,8 +40,8 @@ class OuterEnumIntegerDefaultValue(int, Enum): NUMBER_2 = 2 @classmethod - def from_json(cls, json_str: str) -> OuterEnumIntegerDefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumIntegerDefaultValue from a JSON string""" - return OuterEnumIntegerDefaultValue(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 99e6d598613d..63f89be83d57 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -22,6 +22,11 @@ from pydantic import BaseModel from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterObjectWithEnumProperty(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> OuterObjectWithEnumProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterObjectWithEnumProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> OuterObjectWithEnumProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of OuterObjectWithEnumProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return OuterObjectWithEnumProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = OuterObjectWithEnumProperty.model_validate({ + _obj = cls.model_validate({ "str_value": obj.get("str_value"), "value": obj.get("value") }) 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 ddff6aed5763..bf32b209e175 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Parent(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Parent: + def from_json(cls, json_str: str) -> Self: """Create an instance of Parent from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Parent: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Parent from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Parent.model_validate(obj) + return cls.model_validate(obj) - _obj = Parent.model_validate({ + _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) for _k, _v in obj.get("optionalDict").items() 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 0f0e1a4a82c8..b0e13eb77ac5 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ParentWithOptionalDict(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ParentWithOptionalDict: + def from_json(cls, json_str: str) -> Self: """Create an instance of ParentWithOptionalDict from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ParentWithOptionalDict: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ParentWithOptionalDict from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ParentWithOptionalDict.model_validate(obj) + return cls.model_validate(obj) - _obj = ParentWithOptionalDict.model_validate({ + _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) for _k, _v in obj.get("optionalDict").items() 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 a159e8537ce7..172263e3757a 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 @@ -24,6 +24,11 @@ from typing_extensions import Annotated from petstore_api.models.category import Category from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Pet(BaseModel): """ @@ -63,7 +68,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Pet: + def from_json(cls, json_str: str) -> Self: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -86,15 +91,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Pet: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Pet from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Pet.model_validate(obj) + return cls.model_validate(obj) - _obj = Pet.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, "name": obj.get("name"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index 7af8f7ee8e3c..89db853d2ec5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -82,13 +86,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> Pig: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> Pig: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = Pig.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 8bf9238e9386..6686b3996c4a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class PropertyNameCollision(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> PropertyNameCollision: + def from_json(cls, json_str: str) -> Self: """Create an instance of PropertyNameCollision from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -60,15 +65,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> PropertyNameCollision: + def from_dict(cls, obj: dict) -> Self: """Create an instance of PropertyNameCollision from a dict""" if obj is None: return None if not isinstance(obj, dict): - return PropertyNameCollision.model_validate(obj) + return cls.model_validate(obj) - _obj = PropertyNameCollision.model_validate({ + _obj = cls.model_validate({ "_type": obj.get("_type"), "type": obj.get("type"), "type_": obj.get("type_") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index ac17302ac522..36e01e426f4d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ReadOnlyFirst(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ReadOnlyFirst: + def from_json(cls, json_str: str) -> Self: """Create an instance of ReadOnlyFirst from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -59,15 +64,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ReadOnlyFirst: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ReadOnlyFirst from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ReadOnlyFirst.model_validate(obj) + return cls.model_validate(obj) - _obj = ReadOnlyFirst.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar"), "baz": obj.get("baz") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index bf0846fe95ac..e5a50d08455b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SecondRef(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SecondRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of SecondRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SecondRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SecondRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SecondRef.model_validate(obj) + return cls.model_validate(obj) - _obj = SecondRef.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index b05dcf09f6d4..14f9086a65a1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SelfReferenceModel(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SelfReferenceModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of SelfReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -61,15 +66,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SelfReferenceModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SelfReferenceModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SelfReferenceModel.model_validate(obj) + return cls.model_validate(obj) - _obj = SelfReferenceModel.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py index bc1903188499..3c41c4118654 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SingleRefType(str, Enum): @@ -34,8 +38,8 @@ class SingleRefType(str, Enum): USER = 'user' @classmethod - def from_json(cls, json_str: str) -> SingleRefType: + def from_json(cls, json_str: str) -> Self: """Create an instance of SingleRefType from a JSON string""" - return SingleRefType(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py index 0443972f8d75..77ed288a94b4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialCharacterEnum(str, Enum): @@ -42,8 +46,8 @@ class SpecialCharacterEnum(str, Enum): HELLO_WORLD = ' hello world ' @classmethod - def from_json(cls, json_str: str) -> SpecialCharacterEnum: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialCharacterEnum from a JSON string""" - return SpecialCharacterEnum(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index da9365d2ffd3..cfe078d8df25 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialModelName(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SpecialModelName: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialModelName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SpecialModelName: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SpecialModelName from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SpecialModelName.model_validate(obj) + return cls.model_validate(obj) - _obj = SpecialModelName.model_validate({ + _obj = cls.model_validate({ "$special[property.name]": obj.get("$special[property.name]") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index 3cd5fa9d1a98..a1fb520ea4f8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.category import Category +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialName(BaseModel): """ @@ -58,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SpecialName: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -74,15 +79,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SpecialName: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SpecialName from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SpecialName.model_validate(obj) + return cls.model_validate(obj) - _obj = SpecialName.model_validate({ + _obj = cls.model_validate({ "property": obj.get("property"), "async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None, "schema": obj.get("schema") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index e8ea593fc135..5a2ec6cac274 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tag(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tag: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -58,15 +63,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tag: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tag from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tag.model_validate(obj) + return cls.model_validate(obj) - _obj = Tag.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index 3b90bf2d077e..f1f9b070aeaa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestInlineFreeformAdditionalPropertiesRequest: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestInlineFreeformAdditionalPropertiesRequest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestInlineFreeformAdditionalPropertiesRequest.model_validate(obj) + return cls.model_validate(obj) - _obj = TestInlineFreeformAdditionalPropertiesRequest.model_validate({ + _obj = cls.model_validate({ "someProperty": obj.get("someProperty") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 366ac1aa055b..a849fb20b946 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -20,6 +20,11 @@ from typing import Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tiger(BaseModel): """ @@ -44,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tiger: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tiger from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -57,15 +62,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tiger: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tiger from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tiger.model_validate(obj) + return cls.model_validate(obj) - _obj = Tiger.model_validate({ + _obj = cls.model_validate({ "skill": obj.get("skill") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index ed573fa7703f..61a0875b1ab0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -21,6 +21,11 @@ from typing import Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class User(BaseModel): """ @@ -52,7 +57,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> User: + def from_json(cls, json_str: str) -> Self: """Create an instance of User from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> User: + def from_dict(cls, obj: dict) -> Self: """Create an instance of User from a dict""" if obj is None: return None if not isinstance(obj, dict): - return User.model_validate(obj) + return cls.model_validate(obj) - _obj = User.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "username": obj.get("username"), "firstName": obj.get("firstName"), diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index d06b1bd633de..b93c56e374fb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class WithNestedOneOf(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> WithNestedOneOf: + def from_json(cls, json_str: str) -> Self: """Create an instance of WithNestedOneOf from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,15 +72,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> WithNestedOneOf: + def from_dict(cls, obj: dict) -> Self: """Create an instance of WithNestedOneOf from a dict""" if obj is None: return None if not isinstance(obj, dict): - return WithNestedOneOf.model_validate(obj) + return cls.model_validate(obj) - _obj = WithNestedOneOf.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None, "nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index 195ef38a9ba6..2f9eb8f4c638 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesAnyType(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesAnyType from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesAnyType from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesAnyType.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesAnyType.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties 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 448082d20922..d7aafaffce05 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 @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesClass(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesClass.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesClass.model_validate({ + _obj = cls.model_validate({ "map_property": obj.get("map_property"), "map_of_map_property": obj.get("map_of_map_property") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index f6028c9bf57f..0fc6c73f6412 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesObject(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesObject: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesObject: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesObject from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesObject.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesObject.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index 4d72bd363159..aaa0f5892f93 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AdditionalPropertiesWithDescriptionOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AdditionalPropertiesWithDescriptionOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AdditionalPropertiesWithDescriptionOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = AdditionalPropertiesWithDescriptionOnly.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index f0d179f87529..892a4e19f53e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field from petstore_api.models.single_ref_type import SingleRefType +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class AllOfWithSingleRef(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> AllOfWithSingleRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of AllOfWithSingleRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,15 +72,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> AllOfWithSingleRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of AllOfWithSingleRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return AllOfWithSingleRef.model_validate(obj) + return cls.model_validate(obj) - _obj = AllOfWithSingleRef.model_validate({ + _obj = cls.model_validate({ "username": obj.get("username"), "SingleRefType": obj.get("SingleRefType") }) 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 55f9889c8eb1..e22f31c0b745 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Animal(BaseModel): """ @@ -64,7 +69,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union(Cat, Dog): + def from_json(cls, json_str: str) -> Union[Self, Self]: """Create an instance of Animal from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -83,7 +88,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Union(Cat, Dog): + def from_dict(cls, obj: dict) -> Union[Self, Self]: """Create an instance of Animal from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index 23097a497506..db4718b868b0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -88,13 +92,13 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> AnyOfColor: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> AnyOfColor: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = AnyOfColor.model_construct() + instance = cls.model_construct() error_messages = [] # deserialize data into List[int] try: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index 00369b878bd3..2a2a04932225 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -80,13 +84,13 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> AnyOfPig: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> AnyOfPig: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = AnyOfPig.model_construct() + instance = cls.model_construct() error_messages = [] # anyof_schema_1_validator: Optional[BasquePig] = None try: diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py index 562069d7db95..c22c0c8612e9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ApiResponse(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ApiResponse: + def from_json(cls, json_str: str) -> Self: """Create an instance of ApiResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ApiResponse: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ApiResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ApiResponse.model_validate(obj) + return cls.model_validate(obj) - _obj = ApiResponse.model_validate({ + _obj = cls.model_validate({ "code": obj.get("code"), "type": obj.get("type"), "message": obj.get("message") 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 21eacad79a34..3b7b337d961c 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 @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfArrayOfModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfArrayOfModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -74,15 +79,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfArrayOfModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfArrayOfModel.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfArrayOfModel.model_validate({ + _obj = cls.model_validate({ "another_property": [ [Tag.from_dict(_inner_item) for _inner_item in _item] for _item in obj.get("another_property") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index d934fac1f56b..33ac181d87c4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictFloat from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfArrayOfNumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfArrayOfNumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfArrayOfNumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfArrayOfNumberOnly.model_validate({ + _obj = cls.model_validate({ "ArrayArrayNumber": obj.get("ArrayArrayNumber") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index e3d3e6c6bb82..7a32c25c353a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictFloat from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayOfNumberOnly(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayOfNumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayOfNumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayOfNumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayOfNumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayOfNumberOnly.model_validate({ + _obj = cls.model_validate({ "ArrayNumber": obj.get("ArrayNumber") }) # store additional fields in additional_properties 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 b49970b7f85c..6a02dedc4a30 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 @@ -23,6 +23,11 @@ from pydantic import Field from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ArrayTest(BaseModel): """ @@ -50,7 +55,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ArrayTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of ArrayTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -78,15 +83,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ArrayTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ArrayTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ArrayTest.model_validate(obj) + return cls.model_validate(obj) - _obj = ArrayTest.model_validate({ + _obj = cls.model_validate({ "array_of_string": obj.get("array_of_string"), "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index 55c35407bf77..c737c7c4c028 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class BasquePig(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> BasquePig: + def from_json(cls, json_str: str) -> Self: """Create an instance of BasquePig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> BasquePig: + def from_dict(cls, obj: dict) -> Self: """Create an instance of BasquePig from a dict""" if obj is None: return None if not isinstance(obj, dict): - return BasquePig.model_validate(obj) + return cls.model_validate(obj) - _obj = BasquePig.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index d05dfaea7365..3665cba2db07 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Capitalization(BaseModel): """ @@ -51,7 +56,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Capitalization: + def from_json(cls, json_str: str) -> Self: """Create an instance of Capitalization from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -70,15 +75,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Capitalization: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Capitalization from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Capitalization.model_validate(obj) + return cls.model_validate(obj) - _obj = Capitalization.model_validate({ + _obj = cls.model_validate({ "smallCamel": obj.get("smallCamel"), "CapitalCamel": obj.get("CapitalCamel"), "small_Snake": obj.get("small_Snake"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index 224d78427df5..874214e53967 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import StrictBool from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Cat(Animal): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Cat: + def from_json(cls, json_str: str) -> Self: """Create an instance of Cat from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Cat: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Cat from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Cat.model_validate(obj) + return cls.model_validate(obj) - _obj = Cat.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") if obj.get("color") is not None else 'red', "declawed": obj.get("declawed") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index eadddb42b72e..a23541d85110 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Category(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Category: + def from_json(cls, json_str: str) -> Self: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Category: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Category from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Category.model_validate(obj) + return cls.model_validate(obj) - _obj = Category.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") if obj.get("name") is not None else 'default-name' }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index ebea0cac3a28..741adfb4690e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class CircularReferenceModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> CircularReferenceModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of CircularReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> CircularReferenceModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of CircularReferenceModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CircularReferenceModel.model_validate(obj) + return cls.model_validate(obj) - _obj = CircularReferenceModel.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 7ce61a06aadd..0db491e2100e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ClassModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ClassModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of ClassModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ClassModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ClassModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ClassModel.model_validate(obj) + return cls.model_validate(obj) - _obj = ClassModel.model_validate({ + _obj = cls.model_validate({ "_class": obj.get("_class") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index c66b3af98f70..12a566e2ae9e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Client(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Client: + def from_json(cls, json_str: str) -> Self: """Create an instance of Client from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Client: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Client from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Client.model_validate(obj) + return cls.model_validate(obj) - _obj = Client.model_validate({ + _obj = cls.model_validate({ "client": obj.get("client") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index 2fdc7e8805cf..b5abaccbd0ba 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -92,13 +96,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> Color: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> Color: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = Color.model_construct() + instance = cls.model_construct() if json_str is None: return instance 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 63391047e32f..e19ca3cb663e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List from pydantic import BaseModel, StrictStr from petstore_api.models.creature_info import CreatureInfo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Creature(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Creature: + def from_json(cls, json_str: str) -> Self: """Create an instance of Creature from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -69,15 +74,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Creature: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Creature from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Creature.model_validate(obj) + return cls.model_validate(obj) - _obj = Creature.model_validate({ + _obj = cls.model_validate({ "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, "type": obj.get("type") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index e5a55e5329ff..ca057aad1cb4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class CreatureInfo(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> CreatureInfo: + def from_json(cls, json_str: str) -> Self: """Create an instance of CreatureInfo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> CreatureInfo: + def from_dict(cls, obj: dict) -> Self: """Create an instance of CreatureInfo from a dict""" if obj is None: return None if not isinstance(obj, dict): - return CreatureInfo.model_validate(obj) + return cls.model_validate(obj) - _obj = CreatureInfo.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index 185a50859626..431fe589fa64 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DanishPig(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DanishPig: + def from_json(cls, json_str: str) -> Self: """Create an instance of DanishPig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DanishPig: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DanishPig from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DanishPig.model_validate(obj) + return cls.model_validate(obj) - _obj = DanishPig.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "size": obj.get("size") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 61e966b24a03..6ecd3752d938 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DeprecatedObject(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DeprecatedObject: + def from_json(cls, json_str: str) -> Self: """Create an instance of DeprecatedObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DeprecatedObject: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DeprecatedObject from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DeprecatedObject.model_validate(obj) + return cls.model_validate(obj) - _obj = DeprecatedObject.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index 924859c2ae70..e64ecdc3eb3e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import StrictStr from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Dog(Animal): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Dog: + def from_json(cls, json_str: str) -> Self: """Create an instance of Dog from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Dog: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Dog from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Dog.model_validate(obj) + return cls.model_validate(obj) - _obj = Dog.model_validate({ + _obj = cls.model_validate({ "className": obj.get("className"), "color": obj.get("color") if obj.get("color") is not None else 'red', "breed": obj.get("breed") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 74afee150324..47c1f70cce97 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class DummyModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> DummyModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of DummyModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> DummyModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of DummyModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return DummyModel.model_validate(obj) + return cls.model_validate(obj) - _obj = DummyModel.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index c04e41b7b4a7..54319e5347e2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr, field_validator +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumArrays(BaseModel): """ @@ -67,7 +72,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> EnumArrays: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumArrays from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -86,15 +91,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> EnumArrays: + def from_dict(cls, obj: dict) -> Self: """Create an instance of EnumArrays from a dict""" if obj is None: return None if not isinstance(obj, dict): - return EnumArrays.model_validate(obj) + return cls.model_validate(obj) - _obj = EnumArrays.model_validate({ + _obj = cls.model_validate({ "just_symbol": obj.get("just_symbol"), "array_enum": obj.get("array_enum") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py index b7d443776def..11255f418979 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumClass(str, Enum): @@ -35,8 +39,8 @@ class EnumClass(str, Enum): LEFT_PARENTHESIS_XYZ_RIGHT_PARENTHESIS = '(xyz)' @classmethod - def from_json(cls, json_str: str) -> EnumClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumClass from a JSON string""" - return EnumClass(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py index 71f9f0c10c15..efe9a6056218 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString1(str, Enum): @@ -34,8 +38,8 @@ class EnumString1(str, Enum): B = 'b' @classmethod - def from_json(cls, json_str: str) -> EnumString1: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString1 from a JSON string""" - return EnumString1(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py index 2cba894b5d79..222c5dc6b824 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString2(str, Enum): @@ -34,8 +38,8 @@ class EnumString2(str, Enum): D = 'd' @classmethod - def from_json(cls, json_str: str) -> EnumString2: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumString2 from a JSON string""" - return EnumString2(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 1138ee69bba2..805f1e539bf1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -25,6 +25,11 @@ from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumTest(BaseModel): """ @@ -105,7 +110,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> EnumTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of EnumTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -129,15 +134,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> EnumTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of EnumTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return EnumTest.model_validate(obj) + return cls.model_validate(obj) - _obj = EnumTest.model_validate({ + _obj = cls.model_validate({ "enum_string": obj.get("enum_string"), "enum_string_required": obj.get("enum_string_required"), "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index 35827d95ec3a..7bd7a44301e7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class File(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> File: + def from_json(cls, json_str: str) -> Self: """Create an instance of File from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> File: + def from_dict(cls, obj: dict) -> Self: """Create an instance of File from a dict""" if obj is None: return None if not isinstance(obj, dict): - return File.model_validate(obj) + return cls.model_validate(obj) - _obj = File.model_validate({ + _obj = cls.model_validate({ "sourceURI": obj.get("sourceURI") }) # store additional fields in additional_properties 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 b11444edfc81..481d7d49ca10 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 @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel from petstore_api.models.file import File +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FileSchemaTestClass(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FileSchemaTestClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of FileSchemaTestClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -76,15 +81,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FileSchemaTestClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FileSchemaTestClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FileSchemaTestClass.model_validate(obj) + return cls.model_validate(obj) - _obj = FileSchemaTestClass.model_validate({ + _obj = cls.model_validate({ "file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None, "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index 007265a6042c..cb18b14dd1d4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FirstRef(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FirstRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of FirstRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FirstRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FirstRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FirstRef.model_validate(obj) + return cls.model_validate(obj) - _obj = FirstRef.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 97d1400aeef8..5f76a765d8c9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Foo(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Foo: + def from_json(cls, json_str: str) -> Self: """Create an instance of Foo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Foo: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Foo from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Foo.model_validate(obj) + return cls.model_validate(obj) - _obj = Foo.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index 493a56736afe..5f7f93a7b4b8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel from petstore_api.models.foo import Foo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FooGetDefaultResponse(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FooGetDefaultResponse: + def from_json(cls, json_str: str) -> Self: """Create an instance of FooGetDefaultResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FooGetDefaultResponse: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FooGetDefaultResponse from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FooGetDefaultResponse.model_validate(obj) + return cls.model_validate(obj) - _obj = FooGetDefaultResponse.model_validate({ + _obj = cls.model_validate({ "string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 469e4093b628..092e6bfae265 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -23,6 +23,11 @@ from decimal import Decimal from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class FormatTest(BaseModel): """ @@ -104,7 +109,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> FormatTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of FormatTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -123,15 +128,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> FormatTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of FormatTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return FormatTest.model_validate(obj) + return cls.model_validate(obj) - _obj = FormatTest.model_validate({ + _obj = cls.model_validate({ "integer": obj.get("integer"), "int32": obj.get("int32"), "int64": obj.get("int64"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index d24948864e0a..209339a79e52 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class HasOnlyReadOnly(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> HasOnlyReadOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of HasOnlyReadOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,15 +72,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> HasOnlyReadOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of HasOnlyReadOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return HasOnlyReadOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = HasOnlyReadOnly.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar"), "foo": obj.get("foo") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index a1ebf76f9dee..d1f743a74dde 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class HealthCheckResult(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> HealthCheckResult: + def from_json(cls, json_str: str) -> Self: """Create an instance of HealthCheckResult from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -70,15 +75,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> HealthCheckResult: + def from_dict(cls, obj: dict) -> Self: """Create an instance of HealthCheckResult from a dict""" if obj is None: return None if not isinstance(obj, dict): - return HealthCheckResult.model_validate(obj) + return cls.model_validate(obj) - _obj = HealthCheckResult.model_validate({ + _obj = cls.model_validate({ "NullableMessage": obj.get("NullableMessage") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index 1105ca6df358..c18b231ee550 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from pydantic import BaseModel from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class InnerDictWithProperty(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> InnerDictWithProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of InnerDictWithProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> InnerDictWithProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of InnerDictWithProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return InnerDictWithProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = InnerDictWithProperty.model_validate({ + _obj = cls.model_validate({ "aProperty": obj.get("aProperty") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index 0fb43ecaebb3..cd6f56fdeba5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -81,13 +85,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> IntOrString: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> IntOrString: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = IntOrString.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list.py b/samples/openapi3/client/petstore/python/petstore_api/models/list.py index 2d1ca0f6cff1..95f27b25f95a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list.py @@ -21,6 +21,11 @@ from typing import Any, Dict, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class List(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> List: + def from_json(cls, json_str: str) -> Self: """Create an instance of List from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> List: + def from_dict(cls, obj: dict) -> Self: """Create an instance of List from a dict""" if obj is None: return None if not isinstance(obj, dict): - return List.model_validate(obj) + return cls.model_validate(obj) - _obj = List.model_validate({ + _obj = cls.model_validate({ "123-list": obj.get("123-list") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index 1ffb492b72a9..d8ea6a1522a5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ListClass(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ListClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of ListClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ListClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ListClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ListClass.model_validate(obj) + return cls.model_validate(obj) - _obj = ListClass.model_validate({ + _obj = cls.model_validate({ "123-list": obj.get("123-list") }) # store additional fields in additional_properties 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 8db9f4e75354..14ea5bbbfed7 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MapOfArrayOfModel(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MapOfArrayOfModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of MapOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,15 +80,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MapOfArrayOfModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MapOfArrayOfModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MapOfArrayOfModel.model_validate(obj) + return cls.model_validate(obj) - _obj = MapOfArrayOfModel.model_validate({ + _obj = cls.model_validate({ "shopIdToOrgOnlineLipMap": dict( (_k, [Tag.from_dict(_item) for _item in _v] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index e6472e6d41e7..5264cfb66ccc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictBool, StrictStr, field_validator +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MapTest(BaseModel): """ @@ -58,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MapTest: + def from_json(cls, json_str: str) -> Self: """Create an instance of MapTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -77,15 +82,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MapTest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MapTest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MapTest.model_validate(obj) + return cls.model_validate(obj) - _obj = MapTest.model_validate({ + _obj = cls.model_validate({ "map_map_of_string": obj.get("map_map_of_string"), "map_of_enum_string": obj.get("map_of_enum_string"), "direct_map": obj.get("direct_map"), 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 866bd727b94d..4dec79f0b085 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictStr from pydantic import Field from petstore_api.models.animal import Animal +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> MixedPropertiesAndAdditionalPropertiesClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,15 +80,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> MixedPropertiesAndAdditionalPropertiesClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return MixedPropertiesAndAdditionalPropertiesClass.model_validate(obj) + return cls.model_validate(obj) - _obj = MixedPropertiesAndAdditionalPropertiesClass.model_validate({ + _obj = cls.model_validate({ "uuid": obj.get("uuid"), "dateTime": obj.get("dateTime"), "map": dict( diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index ad735d59e1d4..f4c8a38fef12 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Model200Response(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Model200Response: + def from_json(cls, json_str: str) -> Self: """Create an instance of Model200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Model200Response: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Model200Response from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Model200Response.model_validate(obj) + return cls.model_validate(obj) - _obj = Model200Response.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name"), "class": obj.get("class") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index fe885761c7aa..3d1570ac64bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ModelReturn(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ModelReturn: + def from_json(cls, json_str: str) -> Self: """Create an instance of ModelReturn from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ModelReturn: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ModelReturn from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ModelReturn.model_validate(obj) + return cls.model_validate(obj) - _obj = ModelReturn.model_validate({ + _obj = cls.model_validate({ "return": obj.get("return") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index f0f1a15dba8d..88c941185cd5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Name(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Name: + def from_json(cls, json_str: str) -> Self: """Create an instance of Name from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -70,15 +75,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Name: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Name from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Name.model_validate(obj) + return cls.model_validate(obj) - _obj = Name.model_validate({ + _obj = cls.model_validate({ "name": obj.get("name"), "snake_case": obj.get("snake_case"), "property": obj.get("property"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index 133edab35fa1..b71a02ef831c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -20,6 +20,11 @@ from datetime import date, datetime from typing import Any, ClassVar, Dict, List, Optional, Union from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NullableClass(BaseModel): """ @@ -57,7 +62,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NullableClass: + def from_json(cls, json_str: str) -> Self: """Create an instance of NullableClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -131,15 +136,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NullableClass: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NullableClass from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NullableClass.model_validate(obj) + return cls.model_validate(obj) - _obj = NullableClass.model_validate({ + _obj = cls.model_validate({ "required_integer_prop": obj.get("required_integer_prop"), "integer_prop": obj.get("integer_prop"), "number_prop": obj.get("number_prop"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 7c011e64af7f..eff23d4d3235 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt, field_validator from pydantic import Field from typing_extensions import Annotated +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NullableProperty(BaseModel): """ @@ -58,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NullableProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of NullableProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -82,15 +87,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NullableProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NullableProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NullableProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = NullableProperty.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index 1d3bec3e4f13..92760b826e1e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictFloat from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class NumberOnly(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> NumberOnly: + def from_json(cls, json_str: str) -> Self: """Create an instance of NumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> NumberOnly: + def from_dict(cls, obj: dict) -> Self: """Create an instance of NumberOnly from a dict""" if obj is None: return None if not isinstance(obj, dict): - return NumberOnly.model_validate(obj) + return cls.model_validate(obj) - _obj = NumberOnly.model_validate({ + _obj = cls.model_validate({ "JustNumber": obj.get("JustNumber") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 67f3a95c0844..b831f3cf185f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictBool from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ObjectToTestAdditionalProperties(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ObjectToTestAdditionalProperties: + def from_json(cls, json_str: str) -> Self: """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ObjectToTestAdditionalProperties: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ObjectToTestAdditionalProperties from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ObjectToTestAdditionalProperties.model_validate(obj) + return cls.model_validate(obj) - _obj = ObjectToTestAdditionalProperties.model_validate({ + _obj = cls.model_validate({ "property": obj.get("property") if obj.get("property") is not None else False }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 21cabc3ecad3..847199205b5d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictFloat, StrictStr from pydantic import Field from petstore_api.models.deprecated_object import DeprecatedObject +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ObjectWithDeprecatedFields(BaseModel): """ @@ -50,7 +55,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ObjectWithDeprecatedFields: + def from_json(cls, json_str: str) -> Self: """Create an instance of ObjectWithDeprecatedFields from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -72,15 +77,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ObjectWithDeprecatedFields: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ObjectWithDeprecatedFields from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ObjectWithDeprecatedFields.model_validate(obj) + return cls.model_validate(obj) - _obj = ObjectWithDeprecatedFields.model_validate({ + _obj = cls.model_validate({ "uuid": obj.get("uuid"), "id": obj.get("id"), "deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index 65067fe7620e..3e9c111a4a73 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -79,13 +83,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> OneOfEnumString: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> OneOfEnumString: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = OneOfEnumString.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index 887295c377b2..3b619d7f2835 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, field_validator from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Order(BaseModel): """ @@ -61,7 +66,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Order: + def from_json(cls, json_str: str) -> Self: """Create an instance of Order from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,15 +85,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Order: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Order from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Order.model_validate(obj) + return cls.model_validate(obj) - _obj = Order.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "petId": obj.get("petId"), "quantity": obj.get("quantity"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index bfa27a9f71e0..9231182d783c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictBool, StrictFloat, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterComposite(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> OuterComposite: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterComposite from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> OuterComposite: + def from_dict(cls, obj: dict) -> Self: """Create an instance of OuterComposite from a dict""" if obj is None: return None if not isinstance(obj, dict): - return OuterComposite.model_validate(obj) + return cls.model_validate(obj) - _obj = OuterComposite.model_validate({ + _obj = cls.model_validate({ "my_number": obj.get("my_number"), "my_string": obj.get("my_string"), "my_boolean": obj.get("my_boolean") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py index eaed7b602149..89b19cbcf664 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnum(str, Enum): @@ -35,8 +39,8 @@ class OuterEnum(str, Enum): DELIVERED = 'delivered' @classmethod - def from_json(cls, json_str: str) -> OuterEnum: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnum from a JSON string""" - return OuterEnum(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py index 6d3bc533869b..51ca91443e27 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumDefaultValue(str, Enum): @@ -35,8 +39,8 @@ class OuterEnumDefaultValue(str, Enum): DELIVERED = 'delivered' @classmethod - def from_json(cls, json_str: str) -> OuterEnumDefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumDefaultValue from a JSON string""" - return OuterEnumDefaultValue(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py index 0c885e23b9cf..8947df650469 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumInteger(int, Enum): @@ -35,8 +39,8 @@ class OuterEnumInteger(int, Enum): NUMBER_2 = 2 @classmethod - def from_json(cls, json_str: str) -> OuterEnumInteger: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumInteger from a JSON string""" - return OuterEnumInteger(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py index 99ca40483d6a..970487bb0c4d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumIntegerDefaultValue(int, Enum): @@ -36,8 +40,8 @@ class OuterEnumIntegerDefaultValue(int, Enum): NUMBER_2 = 2 @classmethod - def from_json(cls, json_str: str) -> OuterEnumIntegerDefaultValue: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterEnumIntegerDefaultValue from a JSON string""" - return OuterEnumIntegerDefaultValue(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index 888e279f5699..56cd1b3455b5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -22,6 +22,11 @@ from pydantic import BaseModel from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterObjectWithEnumProperty(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> OuterObjectWithEnumProperty: + def from_json(cls, json_str: str) -> Self: """Create an instance of OuterObjectWithEnumProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -72,15 +77,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> OuterObjectWithEnumProperty: + def from_dict(cls, obj: dict) -> Self: """Create an instance of OuterObjectWithEnumProperty from a dict""" if obj is None: return None if not isinstance(obj, dict): - return OuterObjectWithEnumProperty.model_validate(obj) + return cls.model_validate(obj) - _obj = OuterObjectWithEnumProperty.model_validate({ + _obj = cls.model_validate({ "str_value": obj.get("str_value"), "value": obj.get("value") }) 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 9b577c13458f..90bf22d3a497 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Parent(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Parent: + def from_json(cls, json_str: str) -> Self: """Create an instance of Parent from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -73,15 +78,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Parent: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Parent from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Parent.model_validate(obj) + return cls.model_validate(obj) - _obj = Parent.model_validate({ + _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) for _k, _v in obj.get("optionalDict").items() 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 cefb6c6a0225..35ff75ba96e8 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 @@ -22,6 +22,11 @@ from pydantic import BaseModel from pydantic import Field from petstore_api.models.inner_dict_with_property import InnerDictWithProperty +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ParentWithOptionalDict(BaseModel): """ @@ -47,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ParentWithOptionalDict: + def from_json(cls, json_str: str) -> Self: """Create an instance of ParentWithOptionalDict from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -73,15 +78,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ParentWithOptionalDict: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ParentWithOptionalDict from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ParentWithOptionalDict.model_validate(obj) + return cls.model_validate(obj) - _obj = ParentWithOptionalDict.model_validate({ + _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) for _k, _v in obj.get("optionalDict").items() 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 16e34199fc0a..579e271ac1b1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -24,6 +24,11 @@ from typing_extensions import Annotated from petstore_api.models.category import Category from petstore_api.models.tag import Tag +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Pet(BaseModel): """ @@ -64,7 +69,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Pet: + def from_json(cls, json_str: str) -> Self: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -93,15 +98,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Pet: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Pet from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Pet.model_validate(obj) + return cls.model_validate(obj) - _obj = Pet.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, "name": obj.get("name"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 341a4aed0f52..a7912f71a227 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -25,6 +25,10 @@ from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal from pydantic import StrictStr, Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -82,13 +86,13 @@ def actual_instance_must_validate_oneof(cls, v): return v @classmethod - def from_dict(cls, obj: dict) -> Pig: + def from_dict(cls, obj: dict) -> Self: return cls.from_json(json.dumps(obj)) @classmethod - def from_json(cls, json_str: str) -> Pig: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = Pig.model_construct() + instance = cls.model_construct() error_messages = [] match = 0 diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index ddb6723d051e..55ee994a5cb9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class PropertyNameCollision(BaseModel): """ @@ -48,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> PropertyNameCollision: + def from_json(cls, json_str: str) -> Self: """Create an instance of PropertyNameCollision from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,15 +72,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> PropertyNameCollision: + def from_dict(cls, obj: dict) -> Self: """Create an instance of PropertyNameCollision from a dict""" if obj is None: return None if not isinstance(obj, dict): - return PropertyNameCollision.model_validate(obj) + return cls.model_validate(obj) - _obj = PropertyNameCollision.model_validate({ + _obj = cls.model_validate({ "_type": obj.get("_type"), "type": obj.get("type"), "type_": obj.get("type_") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index 9ce549b364b5..77e584231264 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class ReadOnlyFirst(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> ReadOnlyFirst: + def from_json(cls, json_str: str) -> Self: """Create an instance of ReadOnlyFirst from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,15 +71,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> ReadOnlyFirst: + def from_dict(cls, obj: dict) -> Self: """Create an instance of ReadOnlyFirst from a dict""" if obj is None: return None if not isinstance(obj, dict): - return ReadOnlyFirst.model_validate(obj) + return cls.model_validate(obj) - _obj = ReadOnlyFirst.model_validate({ + _obj = cls.model_validate({ "bar": obj.get("bar"), "baz": obj.get("baz") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 8869cb60a1bf..a729974cc611 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SecondRef(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SecondRef: + def from_json(cls, json_str: str) -> Self: """Create an instance of SecondRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SecondRef: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SecondRef from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SecondRef.model_validate(obj) + return cls.model_validate(obj) - _obj = SecondRef.model_validate({ + _obj = cls.model_validate({ "category": obj.get("category"), "circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index adadd56af923..ddd3b78e2443 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SelfReferenceModel(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SelfReferenceModel: + def from_json(cls, json_str: str) -> Self: """Create an instance of SelfReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,15 +73,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SelfReferenceModel: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SelfReferenceModel from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SelfReferenceModel.model_validate(obj) + return cls.model_validate(obj) - _obj = SelfReferenceModel.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py index bc1903188499..3c41c4118654 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SingleRefType(str, Enum): @@ -34,8 +38,8 @@ class SingleRefType(str, Enum): USER = 'user' @classmethod - def from_json(cls, json_str: str) -> SingleRefType: + def from_json(cls, json_str: str) -> Self: """Create an instance of SingleRefType from a JSON string""" - return SingleRefType(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py index 0443972f8d75..77ed288a94b4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialCharacterEnum(str, Enum): @@ -42,8 +46,8 @@ class SpecialCharacterEnum(str, Enum): HELLO_WORLD = ' hello world ' @classmethod - def from_json(cls, json_str: str) -> SpecialCharacterEnum: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialCharacterEnum from a JSON string""" - return SpecialCharacterEnum(json.loads(json_str)) + return cls(json.loads(json_str)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index 56163b1d16ba..2e25f28b9491 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialModelName(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SpecialModelName: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialModelName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SpecialModelName: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SpecialModelName from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SpecialModelName.model_validate(obj) + return cls.model_validate(obj) - _obj = SpecialModelName.model_validate({ + _obj = cls.model_validate({ "$special[property.name]": obj.get("$special[property.name]") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 0d1792c6853f..e6d5e1630cd3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.category import Category +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialName(BaseModel): """ @@ -59,7 +64,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> SpecialName: + def from_json(cls, json_str: str) -> Self: """Create an instance of SpecialName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -81,15 +86,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> SpecialName: + def from_dict(cls, obj: dict) -> Self: """Create an instance of SpecialName from a dict""" if obj is None: return None if not isinstance(obj, dict): - return SpecialName.model_validate(obj) + return cls.model_validate(obj) - _obj = SpecialName.model_validate({ + _obj = cls.model_validate({ "property": obj.get("property"), "async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None, "schema": obj.get("schema") diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index 79513622168f..1d7439781b1e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tag(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tag: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tag: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tag from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tag.model_validate(obj) + return cls.model_validate(obj) - _obj = Tag.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name") }) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index 79aec64aa156..866b6374f44e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -46,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> TestInlineFreeformAdditionalPropertiesRequest: + def from_json(cls, json_str: str) -> Self: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,15 +70,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> TestInlineFreeformAdditionalPropertiesRequest: + def from_dict(cls, obj: dict) -> Self: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): - return TestInlineFreeformAdditionalPropertiesRequest.model_validate(obj) + return cls.model_validate(obj) - _obj = TestInlineFreeformAdditionalPropertiesRequest.model_validate({ + _obj = cls.model_validate({ "someProperty": obj.get("someProperty") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index 7b86ebb40995..19df51a6c6d5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -20,6 +20,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictStr +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class Tiger(BaseModel): """ @@ -45,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Tiger: + def from_json(cls, json_str: str) -> Self: """Create an instance of Tiger from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,15 +69,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Tiger: + def from_dict(cls, obj: dict) -> Self: """Create an instance of Tiger from a dict""" if obj is None: return None if not isinstance(obj, dict): - return Tiger.model_validate(obj) + return cls.model_validate(obj) - _obj = Tiger.model_validate({ + _obj = cls.model_validate({ "skill": obj.get("skill") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index 279dd2875162..ef1312c0c921 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -21,6 +21,11 @@ from typing import Any, ClassVar, Dict, List, Optional from pydantic import BaseModel, StrictInt, StrictStr from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class User(BaseModel): """ @@ -53,7 +58,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> User: + def from_json(cls, json_str: str) -> Self: """Create an instance of User from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -72,15 +77,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> User: + def from_dict(cls, obj: dict) -> Self: """Create an instance of User from a dict""" if obj is None: return None if not isinstance(obj, dict): - return User.model_validate(obj) + return cls.model_validate(obj) - _obj = User.model_validate({ + _obj = cls.model_validate({ "id": obj.get("id"), "username": obj.get("username"), "firstName": obj.get("firstName"), diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index 64c6ef08d9c1..8d336a19c954 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -22,6 +22,11 @@ from pydantic import BaseModel, StrictInt from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self class WithNestedOneOf(BaseModel): """ @@ -49,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> WithNestedOneOf: + def from_json(cls, json_str: str) -> Self: """Create an instance of WithNestedOneOf from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -74,15 +79,15 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> WithNestedOneOf: + def from_dict(cls, obj: dict) -> Self: """Create an instance of WithNestedOneOf from a dict""" if obj is None: return None if not isinstance(obj, dict): - return WithNestedOneOf.model_validate(obj) + return cls.model_validate(obj) - _obj = WithNestedOneOf.model_validate({ + _obj = cls.model_validate({ "size": obj.get("size"), "nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None, "nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None