From 150c654cbb45f3393e9c4d77be0c8bf2592cd632 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sat, 30 Sep 2023 09:51:57 +0200 Subject: [PATCH 1/2] python: type generated client using Self This doesn't offer a clear win but this helps for: * Using modern types and making the typing intent clearer * Decreasing the need for `from __future__ import annotations`, since a class can now refer to itself without using its name * Using more `cls` to automatically refer to the class, instead of respecifying the class name every time Self is available from Python 3.11 and is provided in typing_extensions (since 4.0.0) as a fallback for older versions See: https://peps.python.org/pep-0673/ See: https://github.com/python/typing_extensions/blob/main/CHANGELOG.md#added-in-version-400 --- .../main/resources/python/model_anyof.mustache | 10 +++++++--- .../main/resources/python/model_enum.mustache | 8 ++++++-- .../main/resources/python/model_generic.mustache | 16 +++++++++++----- .../main/resources/python/model_oneof.mustache | 10 +++++++--- .../python/openapi_client/models/bird.py | 13 +++++++++---- .../python/openapi_client/models/category.py | 13 +++++++++---- .../python/openapi_client/models/data_query.py | 13 +++++++++---- .../openapi_client/models/default_value.py | 13 +++++++++---- .../models/number_properties_only.py | 13 +++++++++---- .../echo_api/python/openapi_client/models/pet.py | 13 +++++++++---- .../python/openapi_client/models/query.py | 9 +++++++-- .../openapi_client/models/string_enum_ref.py | 8 ++++++-- .../echo_api/python/openapi_client/models/tag.py | 13 +++++++++---- ..._true_object_all_of_query_object_parameter.py | 13 +++++++++---- ...e_true_array_string_query_object_parameter.py | 13 +++++++++---- .../models/additional_properties_any_type.py | 13 +++++++++---- .../models/additional_properties_class.py | 13 +++++++++---- .../models/additional_properties_object.py | 13 +++++++++---- ...dditional_properties_with_description_only.py | 13 +++++++++---- .../models/all_of_with_single_ref.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/animal.py | 9 +++++++-- .../petstore_api/models/any_of_color.py | 10 +++++++--- .../petstore_api/models/any_of_pig.py | 10 +++++++--- .../petstore_api/models/api_response.py | 13 +++++++++---- .../models/array_of_array_of_model.py | 13 +++++++++---- .../models/array_of_array_of_number_only.py | 13 +++++++++---- .../petstore_api/models/array_of_number_only.py | 13 +++++++++---- .../petstore_api/models/array_test.py | 13 +++++++++---- .../petstore_api/models/basque_pig.py | 13 +++++++++---- .../petstore_api/models/capitalization.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/cat.py | 13 +++++++++---- .../petstore_api/models/category.py | 13 +++++++++---- .../models/circular_reference_model.py | 13 +++++++++---- .../petstore_api/models/class_model.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/client.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/color.py | 10 +++++++--- .../petstore_api/models/creature.py | 13 +++++++++---- .../petstore_api/models/creature_info.py | 13 +++++++++---- .../petstore_api/models/danish_pig.py | 13 +++++++++---- .../petstore_api/models/deprecated_object.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/dog.py | 13 +++++++++---- .../petstore_api/models/dummy_model.py | 13 +++++++++---- .../petstore_api/models/enum_arrays.py | 13 +++++++++---- .../petstore_api/models/enum_class.py | 8 ++++++-- .../petstore_api/models/enum_string1.py | 8 ++++++-- .../petstore_api/models/enum_string2.py | 8 ++++++-- .../petstore_api/models/enum_test.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/file.py | 13 +++++++++---- .../models/file_schema_test_class.py | 13 +++++++++---- .../petstore_api/models/first_ref.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/foo.py | 13 +++++++++---- .../models/foo_get_default_response.py | 13 +++++++++---- .../petstore_api/models/format_test.py | 13 +++++++++---- .../petstore_api/models/has_only_read_only.py | 13 +++++++++---- .../petstore_api/models/health_check_result.py | 13 +++++++++---- .../models/inner_dict_with_property.py | 13 +++++++++---- .../petstore_api/models/int_or_string.py | 10 +++++++--- .../python-aiohttp/petstore_api/models/list.py | 13 +++++++++---- .../petstore_api/models/map_of_array_of_model.py | 13 +++++++++---- .../petstore_api/models/map_test.py | 13 +++++++++---- ...properties_and_additional_properties_class.py | 13 +++++++++---- .../petstore_api/models/model200_response.py | 13 +++++++++---- .../petstore_api/models/model_return.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/name.py | 13 +++++++++---- .../petstore_api/models/nullable_class.py | 13 +++++++++---- .../petstore_api/models/nullable_property.py | 13 +++++++++---- .../petstore_api/models/number_only.py | 13 +++++++++---- .../object_to_test_additional_properties.py | 13 +++++++++---- .../models/object_with_deprecated_fields.py | 13 +++++++++---- .../petstore_api/models/one_of_enum_string.py | 10 +++++++--- .../python-aiohttp/petstore_api/models/order.py | 13 +++++++++---- .../petstore_api/models/outer_composite.py | 13 +++++++++---- .../petstore_api/models/outer_enum.py | 8 ++++++-- .../models/outer_enum_default_value.py | 8 ++++++-- .../petstore_api/models/outer_enum_integer.py | 8 ++++++-- .../models/outer_enum_integer_default_value.py | 8 ++++++-- .../models/outer_object_with_enum_property.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/parent.py | 13 +++++++++---- .../models/parent_with_optional_dict.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/pet.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/pig.py | 10 +++++++--- .../models/property_name_collision.py | 13 +++++++++---- .../petstore_api/models/read_only_first.py | 13 +++++++++---- .../petstore_api/models/second_ref.py | 13 +++++++++---- .../petstore_api/models/self_reference_model.py | 13 +++++++++---- .../petstore_api/models/single_ref_type.py | 8 ++++++-- .../models/special_character_enum.py | 8 ++++++-- .../petstore_api/models/special_model_name.py | 13 +++++++++---- .../petstore_api/models/special_name.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/tag.py | 13 +++++++++---- ...ine_freeform_additional_properties_request.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/tiger.py | 13 +++++++++---- .../python-aiohttp/petstore_api/models/user.py | 13 +++++++++---- .../petstore_api/models/with_nested_one_of.py | 13 +++++++++---- .../models/additional_properties_any_type.py | 13 +++++++++---- .../models/additional_properties_class.py | 13 +++++++++---- .../models/additional_properties_object.py | 13 +++++++++---- ...dditional_properties_with_description_only.py | 13 +++++++++---- .../models/all_of_with_single_ref.py | 13 +++++++++---- .../python/petstore_api/models/animal.py | 9 +++++++-- .../python/petstore_api/models/any_of_color.py | 10 +++++++--- .../python/petstore_api/models/any_of_pig.py | 10 +++++++--- .../python/petstore_api/models/api_response.py | 13 +++++++++---- .../models/array_of_array_of_model.py | 13 +++++++++---- .../models/array_of_array_of_number_only.py | 13 +++++++++---- .../petstore_api/models/array_of_number_only.py | 13 +++++++++---- .../python/petstore_api/models/array_test.py | 13 +++++++++---- .../python/petstore_api/models/basque_pig.py | 13 +++++++++---- .../python/petstore_api/models/capitalization.py | 13 +++++++++---- .../petstore/python/petstore_api/models/cat.py | 13 +++++++++---- .../python/petstore_api/models/category.py | 13 +++++++++---- .../models/circular_reference_model.py | 13 +++++++++---- .../python/petstore_api/models/class_model.py | 13 +++++++++---- .../python/petstore_api/models/client.py | 13 +++++++++---- .../petstore/python/petstore_api/models/color.py | 10 +++++++--- .../python/petstore_api/models/creature.py | 13 +++++++++---- .../python/petstore_api/models/creature_info.py | 13 +++++++++---- .../python/petstore_api/models/danish_pig.py | 13 +++++++++---- .../petstore_api/models/deprecated_object.py | 13 +++++++++---- .../petstore/python/petstore_api/models/dog.py | 13 +++++++++---- .../python/petstore_api/models/dummy_model.py | 13 +++++++++---- .../python/petstore_api/models/enum_arrays.py | 13 +++++++++---- .../python/petstore_api/models/enum_class.py | 8 ++++++-- .../python/petstore_api/models/enum_string1.py | 8 ++++++-- .../python/petstore_api/models/enum_string2.py | 8 ++++++-- .../python/petstore_api/models/enum_test.py | 13 +++++++++---- .../petstore/python/petstore_api/models/file.py | 13 +++++++++---- .../models/file_schema_test_class.py | 13 +++++++++---- .../python/petstore_api/models/first_ref.py | 13 +++++++++---- .../petstore/python/petstore_api/models/foo.py | 13 +++++++++---- .../models/foo_get_default_response.py | 13 +++++++++---- .../python/petstore_api/models/format_test.py | 13 +++++++++---- .../petstore_api/models/has_only_read_only.py | 13 +++++++++---- .../petstore_api/models/health_check_result.py | 13 +++++++++---- .../models/inner_dict_with_property.py | 13 +++++++++---- .../python/petstore_api/models/int_or_string.py | 10 +++++++--- .../petstore/python/petstore_api/models/list.py | 13 +++++++++---- .../petstore_api/models/map_of_array_of_model.py | 13 +++++++++---- .../python/petstore_api/models/map_test.py | 13 +++++++++---- ...properties_and_additional_properties_class.py | 13 +++++++++---- .../petstore_api/models/model200_response.py | 13 +++++++++---- .../python/petstore_api/models/model_return.py | 13 +++++++++---- .../petstore/python/petstore_api/models/name.py | 13 +++++++++---- .../python/petstore_api/models/nullable_class.py | 13 +++++++++---- .../petstore_api/models/nullable_property.py | 13 +++++++++---- .../python/petstore_api/models/number_only.py | 13 +++++++++---- .../object_to_test_additional_properties.py | 13 +++++++++---- .../models/object_with_deprecated_fields.py | 13 +++++++++---- .../petstore_api/models/one_of_enum_string.py | 10 +++++++--- .../petstore/python/petstore_api/models/order.py | 13 +++++++++---- .../petstore_api/models/outer_composite.py | 13 +++++++++---- .../python/petstore_api/models/outer_enum.py | 8 ++++++-- .../models/outer_enum_default_value.py | 8 ++++++-- .../petstore_api/models/outer_enum_integer.py | 8 ++++++-- .../models/outer_enum_integer_default_value.py | 8 ++++++-- .../models/outer_object_with_enum_property.py | 13 +++++++++---- .../python/petstore_api/models/parent.py | 13 +++++++++---- .../models/parent_with_optional_dict.py | 13 +++++++++---- .../petstore/python/petstore_api/models/pet.py | 13 +++++++++---- .../petstore/python/petstore_api/models/pig.py | 10 +++++++--- .../models/property_name_collision.py | 13 +++++++++---- .../petstore_api/models/read_only_first.py | 13 +++++++++---- .../python/petstore_api/models/second_ref.py | 13 +++++++++---- .../petstore_api/models/self_reference_model.py | 13 +++++++++---- .../petstore_api/models/single_ref_type.py | 8 ++++++-- .../models/special_character_enum.py | 8 ++++++-- .../petstore_api/models/special_model_name.py | 13 +++++++++---- .../python/petstore_api/models/special_name.py | 13 +++++++++---- .../petstore/python/petstore_api/models/tag.py | 13 +++++++++---- ...ine_freeform_additional_properties_request.py | 13 +++++++++---- .../petstore/python/petstore_api/models/tiger.py | 13 +++++++++---- .../petstore/python/petstore_api/models/user.py | 13 +++++++++---- .../petstore_api/models/with_nested_one_of.py | 13 +++++++++---- 173 files changed, 1465 insertions(+), 633 deletions(-) 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 83f0552c7812..56d6d738963a 100644 --- a/modules/openapi-generator/src/main/resources/python/model_enum.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_enum.mustache @@ -5,6 +5,10 @@ from aenum import Enum, no_arg {{#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): @@ -21,9 +25,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 c8a27a42c248..93ad2e247a0c 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}}): """ @@ -119,7 +124,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)) @@ -221,7 +226,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}} @@ -241,18 +246,19 @@ 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}} # raise errors for additional fields in the input + properties = cls.model_json_schema()["properties"] for _key in obj.keys(): - if _key not in cls.__properties: + if _key not in properties: raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj) {{/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/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 13b67878e2e0..fd52eaa3ca50 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 0d4cfdd54dcb..b95c48056c05 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 14f2288d1c0a..dab9d9b96575 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 e807e94e34c2..70b287b0085c 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 23a179ae2a8a..6420edf6b2b0 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): """ @@ -48,7 +53,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)) @@ -61,15 +66,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"), "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 51b1d20275a3..979d2003b87e 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 c96f723c99b7..722400554968 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 f200a1dafb8e..458856f426c5 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 @@ -20,6 +20,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class StringEnumRef(str, Enum): @@ -35,8 +39,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 5e456e33d229..5a5175d35551 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 c809f92c4944..b67872d845df 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 1fef35695999..5e26ecd5c29f 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 434439f1769a..9f3499792063 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 86f52278aa18..777c275c9b1f 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 e05cd9a4752f..3425e0ef7796 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 10e6602941b6..870f7ca7c5c8 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 302f89173e4c..8605169b729e 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 33501c52ed0d..9ec75c878f07 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): """ @@ -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)) @@ -77,7 +82,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 875a41e2aedb..8b1ee34a4d11 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 d798ac121c29..fcdb27b7d988 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 7b25d1d101a5..b1654dd2b481 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 d4ba3bd6da14..f3666485b205 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 c195a37415fb..20fdbeaacd81 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 698016f3faa2..9881f02b72c4 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 dcd0d77e7e12..37ebc55588e9 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 c716c253a479..393f162be7a1 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 861e6e9ee073..ef30f5bac9d1 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 920a3e8135e7..bbccb406aa6d 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 c340fd7de00e..4de45ea26e57 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 1f03d4ffb57f..9e2cda0015e1 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 269294aa24ee..6fce99bff2eb 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 fabe153f31bd..bf946454d83b 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 f1bb9dc52184..cf6676e637be 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 d7689114dc04..4c89a44b94b3 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 ca35796fb144..7e2332b5bf00 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 65765b6922d9..2c3bd7e510d6 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 161fe46cc112..3506ed78daaf 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 f3037885ed67..3ff99b53bcce 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumClass(str, Enum): @@ -34,8 +38,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 8ced7d15629a..371e0047cb2f 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString1(str, Enum): @@ -33,8 +37,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 1ee338109101..aa0be3f108ae 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString2(str, Enum): @@ -33,8 +37,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 347a39e802a3..524de85fcf98 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 4db5067c90bf..236f5381a0fd 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 cacb59dc918c..c20fb28aa16a 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 78dcfa435b3c..03a8174f24ff 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 b26e388a28aa..9f0f4f796853 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 8aa1c763e88b..59409f31d347 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 69980df9fab5..0f22cd9a1f7e 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): """ @@ -102,7 +107,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)) @@ -115,15 +120,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 bdb291e1f6af..fb773094642b 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 7328147fd7ab..15cabecf3d47 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 fabd6b43f09a..83368f5507de 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/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index df4f9d9c4d7c..cb7b3263fb98 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 4745dbbfe80b..572c7a2c0a57 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 0a6374269555..9b70f0c7345a 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 fc1d271ca45e..3d4b4c55e982 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 33c2edf0d81a..43e2a5d4e143 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 31caeb082027..91d0427a11c2 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 df5f2998f01d..6ecc75f94fa9 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 08b1946c58ff..3786e5477a5d 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 384ba5f7aa52..215163704592 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 be3a1b2ce566..d75db95e35ae 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 805d4ce5396b..002792bd4a0a 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 d44585a9dde8..c5d2df4e7376 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 1f6f60549eac..5fdefec57cce 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 bfb06a008b56..0e2d0a4641aa 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnum(str, Enum): @@ -34,8 +38,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 807c36f0fe5f..75d1122add87 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumDefaultValue(str, Enum): @@ -34,8 +38,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 77ae46fa7059..4208fb9bac39 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumInteger(int, Enum): @@ -34,8 +38,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 36381197bb71..4d86eed2c189 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumIntegerDefaultValue(int, Enum): @@ -35,8 +39,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 6ac81887102e..114e86cf7fb4 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 d31cc7b86f39..d838540a05d8 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 c834b3d5f741..44dd67f0eaaa 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 c76cc47797c5..db46797956b6 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 af6d6cc1906e..2c7cd5afb7da 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 8a34b0acc32d..5b7488d68195 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 5202c14fed90..a695ea590f45 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 b6b521e40966..6622474ef6b4 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 7edec4bb32cc..4571e4c52c25 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SingleRefType(str, Enum): @@ -33,8 +37,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 14b8a7e3fd67..873dbee6f757 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialCharacterEnum(str, Enum): @@ -41,8 +45,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 e9c82e37092d..c799874c1c59 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 8cbf678f3c34..93ed1632d288 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 8a7251eefbe1..32dc4b25842e 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 ffda6891843c..d0886a73de25 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 d0678ac15d1f..61973c5a92da 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 b2c1e3c7e3fd..106d1bd80511 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 0d8f7616827f..5499421acc9e 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 1be3065d20f2..9f668d9ad3be 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, 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 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 70e633cdd215..8a672f064138 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, 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): """ @@ -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 c401cd724c55..b2ef40e7d22a 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, 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 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 546c5774950a..27eaa45954ff 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, 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 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 d88e6480c91b..1e38ac3a0d94 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 e5c95fef232e..cb28c76c6633 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, Dict, 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): """ @@ -65,7 +70,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)) @@ -84,7 +89,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 a08e764c93b5..55f77f177ac8 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, Dict, 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 c242a481e59b..cd3908d4ed97 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, 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 d2f8b48a1b49..04c66f75ae9e 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, 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 7b013a257cd6..ddf8afdc219e 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, 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 028329d774a6..e73a56322405 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 c107ca3b05ca..4ac8a18d0b14 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, Dict 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 96466c378060..a16837f50428 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, 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 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 e3f7c2a6ea51..05296dbe163b 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, Dict, 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 6dcba4df529d..5a83a0949158 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, Dict, 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 a1e6b9075495..18afd5fc4b86 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, Dict, 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 d8e9f2252efe..43e57930e320 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, 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 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 278f76d80bc3..6ca2d0a78b5c 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, 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 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 1ed187ed4596..53d8ab645b3b 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, Dict 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 7c8c96572547..4bd86b5d1e5b 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, Dict 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 6ba8851e8dd2..ec7dbbdfc4da 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, Dict 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 3a283d11bce0..e6dac0e68e9d 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, 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 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 a6f8a6d23ccd..b976ae141883 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, Dict, 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 42bed2afa374..983f31d4e86d 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, 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 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 1af1ef9c00d3..96a8ec525a27 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, 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 f3037885ed67..3ff99b53bcce 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumClass(str, Enum): @@ -34,8 +38,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 8ced7d15629a..371e0047cb2f 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString1(str, Enum): @@ -33,8 +37,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 1ee338109101..aa0be3f108ae 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class EnumString2(str, Enum): @@ -33,8 +37,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 937a10fcc5ea..94949bde0ba5 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 80b1564e58f5..38e43c7cb798 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, 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 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 030d9f29edbd..75e13d38a80a 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, 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 900034234a4b..313cfcf80cbe 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, 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 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 cacb692da0c7..0ca2f06a3e18 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, 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 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 ac6ef75e60bc..c8910d9d8bc7 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, Dict, 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 e383796a98fb..14bdf5343be9 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): """ @@ -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)) @@ -122,15 +127,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 50af5287e1ad..8c3d8535805d 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, 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 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 bcb06ace99c7..7a5b242f3111 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, 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 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 e53b2401dd7f..19493ffb2e62 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, 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): """ @@ -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/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index f33be2c87f49..f8e853d63622 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 e08eb788b98d..b8ee05fb1d8f 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, 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): """ @@ -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 fba7f02172ad..d21551d08521 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 f5818228991c..05566cd34ad4 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, Dict, 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 d39ad5cb6bdf..f3a5b3419c69 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, Dict, 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 5b4739037295..69dc769f2b99 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, Dict, 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 4c46cc2ae231..34e307bfbbf4 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, 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 9feb0a3f0a08..cc69d8b9b4cd 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 845ec245db68..20306bbca8ca 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, Dict, 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 30d264be3ac5..c3b3f4fe7e26 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, Dict, 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 a37a6415a925..1c58760db8fc 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 9a082803f8cf..0b05c525e079 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, Dict, 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 5b85be74ab97..abcc7683ac2e 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, Dict, 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 bfb06a008b56..0e2d0a4641aa 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnum(str, Enum): @@ -34,8 +38,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 807c36f0fe5f..75d1122add87 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumDefaultValue(str, Enum): @@ -34,8 +38,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 77ae46fa7059..4208fb9bac39 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumInteger(int, Enum): @@ -34,8 +38,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 36381197bb71..4d86eed2c189 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class OuterEnumIntegerDefaultValue(int, Enum): @@ -35,8 +39,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 fe073e3cc8c5..d5cd872571da 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 3f92a9bdc3d5..8d063254e596 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 54f687f1ea29..51a9d8fd7565 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 d79d9c94df51..3523d6196ac5 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 78d9f97a0262..b054305ce8a4 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, 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 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 581ecdf7b542..5fea918724ab 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, 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 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 286f39e4ae42..81ea4fc1f2b6 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, 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 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 e1c51a1f23e7..a1134912922f 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, Dict, 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 7edec4bb32cc..4571e4c52c25 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SingleRefType(str, Enum): @@ -33,8 +37,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 14b8a7e3fd67..873dbee6f757 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 @@ -19,6 +19,10 @@ +try: + from typing import Self +except ImportError: + from typing_extensions import Self class SpecialCharacterEnum(str, Enum): @@ -41,8 +45,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 0cc61ec6bc36..bf7d6be357a0 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, Dict, 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 d44d2f4fb802..66b6f08de9ed 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 378371978088..aeb1b464df50 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, Dict, 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 1ced9efa5f88..096a9982ac94 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, 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 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 647ac852dd48..bee775402b01 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, 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 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 08330324388f..c486a1152fee 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, Dict, 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 3597922adb15..baa5d6d7ebd8 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 From 3eafec1d46b532f0a2e953680fb277382e5fbd0b Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sun, 1 Oct 2023 16:08:09 +0200 Subject: [PATCH 2/2] generate code --- .../openapi_client/api/auth_api.py | 15 +-- .../openapi_client/api/body_api.py | 99 +++++++-------- .../openapi_client/api/form_api.py | 29 ++--- .../openapi_client/api/header_api.py | 15 +-- .../openapi_client/api/path_api.py | 15 +-- .../openapi_client/api/query_api.py | 113 +++++++++--------- .../openapi_client/models/bird.py | 13 +- .../openapi_client/models/category.py | 13 +- .../openapi_client/models/data_query.py | 13 +- .../openapi_client/models/default_value.py | 13 +- .../models/number_properties_only.py | 13 +- .../openapi_client/models/pet.py | 13 +- .../openapi_client/models/query.py | 9 +- .../openapi_client/models/string_enum_ref.py | 11 +- .../openapi_client/models/tag.py | 13 +- ...ue_object_all_of_query_object_parameter.py | 13 +- ...rue_array_string_query_object_parameter.py | 13 +- .../pyproject.toml | 1 - .../requirements.txt | 1 - .../setup.py | 1 - .../petstore_api/models/list_class.py | 13 +- .../python/petstore_api/models/list_class.py | 13 +- 22 files changed, 260 insertions(+), 192 deletions(-) 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/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/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