From d7dcfcc8686772f537ee058285f7d24cadbd428e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:31:41 +0900 Subject: [PATCH 01/14] [python] replace validator with field_validator --- .../codegen/languages/AbstractPythonCodegen.java | 10 +++++----- .../src/main/resources/python/model_anyof.mustache | 2 +- .../src/main/resources/python/model_generic.mustache | 4 ++-- .../src/main/resources/python/model_oneof.mustache | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java index 15b88422fade..708e04ed0b88 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java @@ -911,13 +911,13 @@ private ModelsMap postProcessModelsMap(ModelsMap objs) { pydanticImports.add("Field"); pydanticImports.add("StrictStr"); pydanticImports.add("ValidationError"); - pydanticImports.add("validator"); + pydanticImports.add("field_validator"); } else if (!model.anyOf.isEmpty()) { // anyOF codegenProperties = model.getComposedSchemas().getAnyOf(); pydanticImports.add("Field"); pydanticImports.add("StrictStr"); pydanticImports.add("ValidationError"); - pydanticImports.add("validator"); + pydanticImports.add("field_validator"); } else { // typical model codegenProperties = model.vars; @@ -1807,7 +1807,7 @@ private PythonType stringType(IJsonSchemaValidationProperties cp) { } if (cp.getPattern() != null) { - pydanticImports.add("validator"); + pydanticImports.add("field_validator"); // use validator instead as regex doesn't support flags, e.g. IGNORECASE //fieldCustomization.add(Locale.ROOT, String.format(Locale.ROOT, "regex=r'%s'", cp.getPattern())); } @@ -1938,7 +1938,7 @@ private PythonType binaryType(IJsonSchemaValidationProperties cp) { strt.constrain("min_length", cp.getMinLength()); } if (cp.getPattern() != null) { - pydanticImports.add("validator"); + pydanticImports.add("field_validator"); // use validator instead as regex doesn't support flags, e.g. IGNORECASE //fieldCustomization.add(Locale.ROOT, String.format(Locale.ROOT, "regex=r'%s'", cp.getPattern())); } @@ -2042,7 +2042,7 @@ private PythonType fromCommon(IJsonSchemaValidationProperties cp) { } if (cp.getIsEnum()) { - pydanticImports.add("validator"); + pydanticImports.add("field_validator"); } if (cp.getIsArray()) { 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 c6cc86610ae3..075f05d21456 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -54,7 +54,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_anyof(cls, v): {{#isNullable}} if v is None: 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 346d24f9d0ab..99cac20d0b62 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -27,7 +27,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#vars}} {{#vendorExtensions.x-regex}} - @validator('{{{name}}}') + @field_validator('{{{name}}}') def {{{name}}}_validate_regular_expression(cls, value): """Validates the regular expression""" {{^required}} @@ -48,7 +48,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/vendorExtensions.x-regex}} {{#isEnum}} - @validator('{{{name}}}') + @field_validator('{{{name}}}') def {{{name}}}_validate_enum(cls, value): """Validates the enum""" {{^required}} 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 20d31bf88907..ce511f02c1e1 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -50,7 +50,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): {{#isNullable}} if v is None: From 757c38078c05aa17f57b4866bab698616290df62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:33:27 +0900 Subject: [PATCH 02/14] [python] replace parse_obj with model_validate --- .../src/main/resources/python/model_generic.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 99cac20d0b62..901b6b1d7cd2 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -240,7 +240,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return None if not isinstance(obj, dict): - return {{{classname}}}.parse_obj(obj) + return {{{classname}}}.model_validate(obj) {{#disallowAdditionalPropertiesIfNotPresent}} {{^isAdditionalPropertiesTrue}} @@ -251,7 +251,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isAdditionalPropertiesTrue}} {{/disallowAdditionalPropertiesIfNotPresent}} - _obj = {{{classname}}}.parse_obj({ + _obj = {{{classname}}}.model_validate({ {{#allVars}} {{#isContainer}} {{#isArray}} From 43122037de14bb5ad90fafdd0513dadcc18e32fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:35:38 +0900 Subject: [PATCH 03/14] [python] replace dict with model_dump --- .../src/main/resources/python/model_anyof.mustache | 2 +- .../src/main/resources/python/model_generic.mustache | 4 ++-- .../src/main/resources/python/model_oneof.mustache | 2 +- 3 files changed, 4 insertions(+), 4 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 075f05d21456..e8233415f3bb 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -174,7 +174,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} 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 901b6b1d7cd2..9ea0a3b92469 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -110,7 +110,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/hasChildren}} def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -124,7 +124,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ {{#vendorExtensions.x-py-readonly}} "{{{.}}}", 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 ce511f02c1e1..09dfd9651097 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -197,7 +197,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} From 64541ba34e9988b32d970b03ca2cc7499abfcaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:39:29 +0900 Subject: [PATCH 04/14] [python] replace construct with model_construct --- .../src/main/resources/python/model_anyof.mustache | 4 ++-- .../src/main/resources/python/model_oneof.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 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 e8233415f3bb..12bb07919cb8 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -61,7 +61,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v {{/isNullable}} - instance = {{{classname}}}.construct() + instance = {{{classname}}}.model_construct() error_messages = [] {{#composedSchemas.anyOf}} # validate data type: {{{dataType}}} @@ -102,7 +102,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} @classmethod def from_json(cls, json_str: str) -> {{{classname}}}: """Returns the object represented by the json string""" - instance = {{{classname}}}.construct() + instance = {{{classname}}}.model_construct() {{#isNullable}} if json_str is None: return instance 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 09dfd9651097..281929bff5ad 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -57,7 +57,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return v {{/isNullable}} - instance = {{{classname}}}.construct() + instance = {{{classname}}}.model_construct() error_messages = [] match = 0 {{#composedSchemas.oneOf}} @@ -101,7 +101,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} @classmethod def from_json(cls, json_str: str) -> {{{classname}}}: """Returns the object represented by the json string""" - instance = {{{classname}}}.construct() + instance = {{{classname}}}.model_construct() {{#isNullable}} if json_str is None: return instance From c03d52f6c2118f2183ce9044f5a89516947d427e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:41:16 +0900 Subject: [PATCH 05/14] [python] replace __fields_set__ with model_fields_set --- .../src/main/resources/python/model_generic.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 9ea0a3b92469..bcb614f55854 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -211,8 +211,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#allVars}} {{#isNullable}} # set to None if {{{name}}} (nullable) is None - # and __fields_set__ contains the field - if self.{{name}} is None and "{{{name}}}" in self.__fields_set__: + # and model_fields_set contains the field + if self.{{name}} is None and "{{{name}}}" in self.model_fields_set: _dict['{{{baseName}}}'] = None {{/isNullable}} From 7f3b20c75d4980781939f398680fb7fdf95f500a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:52:35 +0900 Subject: [PATCH 06/14] [python] replace __fields_set__ in the test cases with model_fields_set --- samples/openapi3/client/petstore/python/tests/test_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index d04fd36c4422..4ec36ff8d9f5 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -367,9 +367,9 @@ def test_enum_ref_property(self): d4 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1, str_value=None) self.assertEqual(d4.to_json(), '{"value": 1, "str_value": null}') d5 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1) - self.assertEqual(d5.__fields_set__, {'value'}) + self.assertEqual(d5.model_fields_set, {'value'}) d5.str_value = None # set None explicitly - self.assertEqual(d5.__fields_set__, {'value', 'str_value'}) + self.assertEqual(d5.model_fields_set, {'value', 'str_value'}) self.assertEqual(d5.to_json(), '{"value": 1, "str_value": null}') def test_valdiator(self): From 2dc8e3aac50861b698cb9b46429f6b9738cf4a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 09:58:49 +0900 Subject: [PATCH 07/14] [python] replace validate_arguments with validate_call --- .../src/main/resources/python/api.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 38356218fc7a..c8319e1a5984 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -6,7 +6,7 @@ import re # noqa: F401 import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError {{#imports}} {{import}} @@ -34,7 +34,7 @@ class {{classname}}: self.api_client = api_client {{#operation}} - @validate_arguments + @validate_call {{#asyncio}} async def {{operationId}}(self, {{#allParams}}{{paramName}} : {{{vendorExtensions.x-py-typing}}}{{^required}} = None{{/required}}, {{/allParams}}**kwargs) -> {{{returnType}}}{{^returnType}}None{{/returnType}}: # noqa: E501 {{/asyncio}} @@ -77,7 +77,7 @@ class {{classname}}: raise ValueError(message) return {{#asyncio}}await {{/asyncio}}self.{{operationId}}_with_http_info({{#allParams}}{{paramName}}, {{/allParams}}**kwargs) # noqa: E501 - @validate_arguments + @validate_call {{#asyncio}} async def {{operationId}}_with_http_info(self, {{#allParams}}{{paramName}} : {{{vendorExtensions.x-py-typing}}}{{^required}} = None{{/required}}, {{/allParams}}**kwargs) -> ApiResponse: # noqa: E501 {{/asyncio}} From 252215568830c36ba781afb4a8246380e17f7b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 10:07:10 +0900 Subject: [PATCH 08/14] [python] replace max_items, min_items with max_length, min_length --- .../openapitools/codegen/languages/AbstractPythonCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java index 708e04ed0b88..2b7c6b1ef1f4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java @@ -1768,10 +1768,10 @@ public PydanticType( private PythonType arrayType(IJsonSchemaValidationProperties cp) { PythonType pt = new PythonType(); if (cp.getMaxItems() != null) { - pt.constrain("max_items", cp.getMaxItems()); + pt.constrain("max_length", cp.getMaxItems()); } if (cp.getMinItems()!= null) { - pt.constrain("min_items", cp.getMinItems()); + pt.constrain("min_length", cp.getMinItems()); } if (cp.getUniqueItems()) { // A unique "array" is a set From 7ae9feda86f797fd3f240d1d1937f5c7f0656f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 10:19:31 +0900 Subject: [PATCH 09/14] [python] replace Config class with model_config --- .../src/main/resources/python/model_anyof.mustache | 5 +++-- .../src/main/resources/python/model_generic.mustache | 9 +++++---- .../src/main/resources/python/model_oneof.mustache | 6 ++++-- 3 files changed, 12 insertions(+), 8 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 12bb07919cb8..f8f3e8f10ee1 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -33,8 +33,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Any = None any_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } {{#discriminator}} discriminator_value_class_map: Dict[str, str] = { 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 bcb614f55854..58ddb4996f9d 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -76,10 +76,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isEnum}} {{/vars}} - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "allow_population_by_field_name": True, + "validate_assignment": True + } + {{#hasChildren}} {{#discriminator}} 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 281929bff5ad..7f461de1def4 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -29,8 +29,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Optional[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]] = None one_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } + {{#discriminator}} discriminator_value_class_map: Dict[str, str] = { From f45c892c2a5c4263c610d051ef17df12cb5d45db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 10:25:26 +0900 Subject: [PATCH 10/14] [python] replace allow_population_by_field_name with populate_by_name --- .../src/main/resources/python/model_generic.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 58ddb4996f9d..c8a27a42c248 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -77,7 +77,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/vars}} model_config = { - "allow_population_by_field_name": True, + "populate_by_name": True, "validate_assignment": True } From 304dc1eafe24377bfe178d3014124e3f8adf4e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 10:26:49 +0900 Subject: [PATCH 11/14] [python] remove {{{classname}}}_ONE_OF_SCHEMAS --- .../src/main/resources/python/model_oneof.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7f461de1def4..83b15304bd50 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -27,7 +27,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} {{/composedSchemas.oneOf}} actual_instance: Optional[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]] = None - one_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] model_config = { "validate_assignment": True From 7c605e2ba2696f9f2eac4ca6f9f4c7051f8c4bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 11:18:56 +0900 Subject: [PATCH 12/14] [python] update test cases --- .../client/petstore/python/tests/test_api_validation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/openapi3/client/petstore/python/tests/test_api_validation.py b/samples/openapi3/client/petstore/python/tests/test_api_validation.py index f99df7edfc06..ababab7cdd4b 100644 --- a/samples/openapi3/client/petstore/python/tests/test_api_validation.py +++ b/samples/openapi3/client/petstore/python/tests/test_api_validation.py @@ -50,17 +50,18 @@ def test_required_param_validation(self): try: self.pet_api.get_pet_by_id() except TypeError as e: - self.assertIn("missing 1 required positional argument: 'pet_id'", str(e)) + self.assertIn("1 validation error for get_pet_by_id", str(e)) + self.assertIn("Missing required argument", str(e)) def test_integer_validation(self): try: self.pet_api.get_pet_by_id("123") except ValidationError as e: - # 1 validation error for GetPetById + # 1 validation error for get_pet_by_id # pet_id # Input should be a valid integer [type=int_type, input_value='123', input_type=str] # For further information visit https://errors.pydantic.dev/2.3/v/int_type - self.assertIn("1 validation error for GetPetById", str(e)) + self.assertIn("1 validation error for get_pet_by_id", str(e)) self.assertIn("Input should be a valid integer", str(e)) def test_string_enum_validation(self): From 3cf6b49b2f5816f1d547b232f534f5ecf8825951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 11:37:36 +0900 Subject: [PATCH 13/14] [python] update samples --- .../python/openapi_client/api/auth_api.py | 6 +- .../python/openapi_client/api/body_api.py | 30 +++--- .../python/openapi_client/api/form_api.py | 10 +- .../python/openapi_client/api/header_api.py | 6 +- .../python/openapi_client/api/path_api.py | 6 +- .../python/openapi_client/api/query_api.py | 34 +++---- .../python/openapi_client/models/bird.py | 17 ++-- .../python/openapi_client/models/category.py | 17 ++-- .../openapi_client/models/data_query.py | 17 ++-- .../openapi_client/models/default_value.py | 33 +++---- .../models/number_properties_only.py | 17 ++-- .../python/openapi_client/models/pet.py | 21 +++-- .../python/openapi_client/models/query.py | 17 ++-- .../python/openapi_client/models/tag.py | 17 ++-- ...ue_object_all_of_query_object_parameter.py | 17 ++-- ...rue_array_string_query_object_parameter.py | 17 ++-- .../petstore_api/api/another_fake_api.py | 6 +- .../petstore_api/api/default_api.py | 6 +- .../petstore_api/api/fake_api.py | 92 +++++++++---------- .../api/fake_classname_tags123_api.py | 6 +- .../petstore_api/api/pet_api.py | 40 ++++---- .../petstore_api/api/store_api.py | 18 ++-- .../petstore_api/api/user_api.py | 34 +++---- .../models/additional_properties_any_type.py | 17 ++-- .../models/additional_properties_class.py | 17 ++-- .../models/additional_properties_object.py | 17 ++-- ...tional_properties_with_description_only.py | 17 ++-- .../models/all_of_with_single_ref.py | 17 ++-- .../petstore_api/models/animal.py | 13 +-- .../petstore_api/models/any_of_color.py | 19 ++-- .../petstore_api/models/any_of_pig.py | 15 +-- .../petstore_api/models/api_response.py | 17 ++-- .../models/array_of_array_of_model.py | 17 ++-- .../models/array_of_array_of_number_only.py | 17 ++-- .../models/array_of_number_only.py | 17 ++-- .../petstore_api/models/array_test.py | 19 ++-- .../petstore_api/models/basque_pig.py | 17 ++-- .../petstore_api/models/capitalization.py | 17 ++-- .../python-aiohttp/petstore_api/models/cat.py | 17 ++-- .../petstore_api/models/category.py | 17 ++-- .../models/circular_reference_model.py | 17 ++-- .../petstore_api/models/class_model.py | 17 ++-- .../petstore_api/models/client.py | 17 ++-- .../petstore_api/models/color.py | 22 +++-- .../petstore_api/models/creature.py | 17 ++-- .../petstore_api/models/creature_info.py | 17 ++-- .../petstore_api/models/danish_pig.py | 17 ++-- .../petstore_api/models/deprecated_object.py | 17 ++-- .../python-aiohttp/petstore_api/models/dog.py | 17 ++-- .../petstore_api/models/dummy_model.py | 17 ++-- .../petstore_api/models/enum_arrays.py | 23 ++--- .../petstore_api/models/enum_test.py | 33 +++---- .../petstore_api/models/file.py | 17 ++-- .../models/file_schema_test_class.py | 17 ++-- .../petstore_api/models/first_ref.py | 17 ++-- .../python-aiohttp/petstore_api/models/foo.py | 17 ++-- .../models/foo_get_default_response.py | 17 ++-- .../petstore_api/models/format_test.py | 27 +++--- .../petstore_api/models/has_only_read_only.py | 17 ++-- .../models/health_check_result.py | 21 +++-- .../models/inner_dict_with_property.py | 17 ++-- .../petstore_api/models/int_or_string.py | 18 ++-- .../petstore_api/models/list.py | 17 ++-- .../models/map_of_array_of_model.py | 17 ++-- .../petstore_api/models/map_test.py | 21 +++-- ...perties_and_additional_properties_class.py | 17 ++-- .../petstore_api/models/model200_response.py | 17 ++-- .../petstore_api/models/model_return.py | 17 ++-- .../petstore_api/models/name.py | 17 ++-- .../petstore_api/models/nullable_class.py | 61 ++++++------ .../petstore_api/models/nullable_property.py | 25 ++--- .../petstore_api/models/number_only.py | 17 ++-- .../object_to_test_additional_properties.py | 17 ++-- .../models/object_with_deprecated_fields.py | 17 ++-- .../petstore_api/models/one_of_enum_string.py | 18 ++-- .../petstore_api/models/order.py | 21 +++-- .../petstore_api/models/outer_composite.py | 17 ++-- .../models/outer_object_with_enum_property.py | 21 +++-- .../petstore_api/models/parent.py | 17 ++-- .../models/parent_with_optional_dict.py | 17 ++-- .../python-aiohttp/petstore_api/models/pet.py | 23 ++--- .../python-aiohttp/petstore_api/models/pig.py | 18 ++-- .../models/property_name_collision.py | 17 ++-- .../petstore_api/models/read_only_first.py | 17 ++-- .../petstore_api/models/second_ref.py | 17 ++-- .../models/self_reference_model.py | 17 ++-- .../petstore_api/models/special_model_name.py | 17 ++-- .../petstore_api/models/special_name.py | 21 +++-- .../python-aiohttp/petstore_api/models/tag.py | 17 ++-- ..._freeform_additional_properties_request.py | 17 ++-- .../petstore_api/models/tiger.py | 17 ++-- .../petstore_api/models/user.py | 17 ++-- .../petstore_api/models/with_nested_one_of.py | 17 ++-- .../petstore_api/api/another_fake_api.py | 6 +- .../python/petstore_api/api/default_api.py | 6 +- .../python/petstore_api/api/fake_api.py | 92 +++++++++---------- .../api/fake_classname_tags123_api.py | 6 +- .../python/petstore_api/api/pet_api.py | 40 ++++---- .../python/petstore_api/api/store_api.py | 18 ++-- .../python/petstore_api/api/user_api.py | 34 +++---- .../models/additional_properties_any_type.py | 17 ++-- .../models/additional_properties_class.py | 17 ++-- .../models/additional_properties_object.py | 17 ++-- ...tional_properties_with_description_only.py | 17 ++-- .../models/all_of_with_single_ref.py | 17 ++-- .../python/petstore_api/models/animal.py | 13 +-- .../petstore_api/models/any_of_color.py | 19 ++-- .../python/petstore_api/models/any_of_pig.py | 15 +-- .../petstore_api/models/api_response.py | 17 ++-- .../models/array_of_array_of_model.py | 17 ++-- .../models/array_of_array_of_number_only.py | 17 ++-- .../models/array_of_number_only.py | 17 ++-- .../python/petstore_api/models/array_test.py | 19 ++-- .../python/petstore_api/models/basque_pig.py | 17 ++-- .../petstore_api/models/capitalization.py | 17 ++-- .../python/petstore_api/models/cat.py | 17 ++-- .../python/petstore_api/models/category.py | 17 ++-- .../models/circular_reference_model.py | 17 ++-- .../python/petstore_api/models/class_model.py | 17 ++-- .../python/petstore_api/models/client.py | 17 ++-- .../python/petstore_api/models/color.py | 22 +++-- .../python/petstore_api/models/creature.py | 17 ++-- .../petstore_api/models/creature_info.py | 17 ++-- .../python/petstore_api/models/danish_pig.py | 17 ++-- .../petstore_api/models/deprecated_object.py | 17 ++-- .../python/petstore_api/models/dog.py | 17 ++-- .../python/petstore_api/models/dummy_model.py | 17 ++-- .../python/petstore_api/models/enum_arrays.py | 23 ++--- .../python/petstore_api/models/enum_test.py | 33 +++---- .../python/petstore_api/models/file.py | 17 ++-- .../models/file_schema_test_class.py | 17 ++-- .../python/petstore_api/models/first_ref.py | 17 ++-- .../python/petstore_api/models/foo.py | 17 ++-- .../models/foo_get_default_response.py | 17 ++-- .../python/petstore_api/models/format_test.py | 27 +++--- .../petstore_api/models/has_only_read_only.py | 17 ++-- .../models/health_check_result.py | 21 +++-- .../models/inner_dict_with_property.py | 17 ++-- .../petstore_api/models/int_or_string.py | 18 ++-- .../python/petstore_api/models/list.py | 17 ++-- .../models/map_of_array_of_model.py | 17 ++-- .../python/petstore_api/models/map_test.py | 21 +++-- ...perties_and_additional_properties_class.py | 17 ++-- .../petstore_api/models/model200_response.py | 17 ++-- .../petstore_api/models/model_return.py | 17 ++-- .../python/petstore_api/models/name.py | 17 ++-- .../petstore_api/models/nullable_class.py | 61 ++++++------ .../petstore_api/models/nullable_property.py | 25 ++--- .../python/petstore_api/models/number_only.py | 17 ++-- .../object_to_test_additional_properties.py | 17 ++-- .../models/object_with_deprecated_fields.py | 17 ++-- .../petstore_api/models/one_of_enum_string.py | 18 ++-- .../python/petstore_api/models/order.py | 21 +++-- .../petstore_api/models/outer_composite.py | 17 ++-- .../models/outer_object_with_enum_property.py | 21 +++-- .../python/petstore_api/models/parent.py | 17 ++-- .../models/parent_with_optional_dict.py | 17 ++-- .../python/petstore_api/models/pet.py | 23 ++--- .../python/petstore_api/models/pig.py | 18 ++-- .../models/property_name_collision.py | 17 ++-- .../petstore_api/models/read_only_first.py | 17 ++-- .../python/petstore_api/models/second_ref.py | 17 ++-- .../models/self_reference_model.py | 17 ++-- .../petstore_api/models/special_model_name.py | 17 ++-- .../petstore_api/models/special_name.py | 21 +++-- .../python/petstore_api/models/tag.py | 17 ++-- ..._freeform_additional_properties_request.py | 17 ++-- .../python/petstore_api/models/tiger.py | 17 ++-- .../python/petstore_api/models/user.py | 17 ++-- .../petstore_api/models/with_nested_one_of.py | 17 ++-- 170 files changed, 1728 insertions(+), 1570 deletions(-) diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index 16ee7463aad7..4e7959696e72 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from openapi_client.api_client import ApiClient @@ -40,7 +40,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_auth_http_basic(self, **kwargs) -> str: # noqa: E501 """To test HTTP basic authentication # noqa: E501 @@ -68,7 +68,7 @@ def test_auth_http_basic(self, **kwargs) -> str: # noqa: E501 raise ValueError(message) return self.test_auth_http_basic_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_auth_http_basic_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """To test HTTP basic authentication # noqa: E501 diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 6969e3bcced5..e3465a71db4c 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -48,7 +48,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_binary_gif(self, **kwargs) -> bytearray: # noqa: E501 """Test binary (gif) response body # noqa: E501 @@ -76,7 +76,7 @@ def test_binary_gif(self, **kwargs) -> bytearray: # noqa: E501 raise ValueError(message) return self.test_binary_gif_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_binary_gif_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Test binary (gif) response body # noqa: E501 @@ -180,7 +180,7 @@ def test_binary_gif_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_body_application_octetstream_binary(self, body : Optional[Union[StrictBytes, StrictStr]] = None, **kwargs) -> str: # noqa: E501 """Test body parameter(s) # noqa: E501 @@ -210,7 +210,7 @@ def test_body_application_octetstream_binary(self, body : Optional[Union[StrictB raise ValueError(message) return self.test_body_application_octetstream_binary_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_body_application_octetstream_binary_with_http_info(self, body : Optional[Union[StrictBytes, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test body parameter(s) # noqa: E501 @@ -332,7 +332,7 @@ def test_body_application_octetstream_binary_with_http_info(self, body : Optiona collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_body_multipart_formdata_array_of_binary(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> str: # noqa: E501 """Test array of binary in multipart mime # noqa: E501 @@ -362,7 +362,7 @@ def test_body_multipart_formdata_array_of_binary(self, files : List[Union[Strict raise ValueError(message) return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> ApiResponse: # noqa: E501 """Test array of binary in multipart mime # noqa: E501 @@ -480,7 +480,7 @@ def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : Li collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_echo_body_free_form_object_response_string(self, body : Annotated[Optional[Dict[str, Any]], Field(description="Free form object")] = None, **kwargs) -> str: # noqa: E501 """Test free form object # noqa: E501 @@ -510,7 +510,7 @@ def test_echo_body_free_form_object_response_string(self, body : Annotated[Optio raise ValueError(message) return self.test_echo_body_free_form_object_response_string_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_echo_body_free_form_object_response_string_with_http_info(self, body : Annotated[Optional[Dict[str, Any]], Field(description="Free form object")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test free form object # noqa: E501 @@ -627,7 +627,7 @@ def test_echo_body_free_form_object_response_string_with_http_info(self, body : collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_echo_body_pet(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> Pet: # noqa: E501 """Test body parameter(s) # noqa: E501 @@ -657,7 +657,7 @@ def test_echo_body_pet(self, pet : Annotated[Optional[Pet], Field(description="P raise ValueError(message) return self.test_echo_body_pet_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_echo_body_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test body parameter(s) # noqa: E501 @@ -774,7 +774,7 @@ def test_echo_body_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_echo_body_pet_response_string(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> str: # noqa: E501 """Test empty response body # noqa: E501 @@ -804,7 +804,7 @@ def test_echo_body_pet_response_string(self, pet : Annotated[Optional[Pet], Fiel raise ValueError(message) return self.test_echo_body_pet_response_string_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_echo_body_pet_response_string_with_http_info(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test empty response body # noqa: E501 @@ -921,7 +921,7 @@ def test_echo_body_pet_response_string_with_http_info(self, pet : Annotated[Opti collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_echo_body_tag_response_string(self, tag : Annotated[Optional[Tag], Field(description="Tag object")] = None, **kwargs) -> str: # noqa: E501 """Test empty json (request body) # noqa: E501 @@ -951,7 +951,7 @@ def test_echo_body_tag_response_string(self, tag : Annotated[Optional[Tag], Fiel raise ValueError(message) return self.test_echo_body_tag_response_string_with_http_info(tag, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_echo_body_tag_response_string_with_http_info(self, tag : Annotated[Optional[Tag], Field(description="Tag object")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test empty json (request body) # noqa: E501 diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 7b0f9720c6c9..7d92389ace76 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import StrictBool, StrictInt, StrictStr @@ -44,7 +44,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_form_integer_boolean_string(self, integer_form : Optional[StrictInt] = None, boolean_form : Optional[StrictBool] = None, string_form : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 """Test form parameter(s) # noqa: E501 @@ -78,7 +78,7 @@ def test_form_integer_boolean_string(self, integer_form : Optional[StrictInt] = raise ValueError(message) return self.test_form_integer_boolean_string_with_http_info(integer_form, boolean_form, string_form, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_form_integer_boolean_string_with_http_info(self, integer_form : Optional[StrictInt] = None, boolean_form : Optional[StrictBool] = None, string_form : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test form parameter(s) # noqa: E501 @@ -207,7 +207,7 @@ def test_form_integer_boolean_string_with_http_info(self, integer_form : Optiona collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_form_oneof(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 """Test form parameter(s) for oneOf schema # noqa: E501 @@ -247,7 +247,7 @@ def test_form_oneof(self, form1 : Optional[StrictStr] = None, form2 : Optional[S raise ValueError(message) return self.test_form_oneof_with_http_info(form1, form2, form3, form4, id, name, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_form_oneof_with_http_info(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test form parameter(s) for oneOf schema # noqa: E501 diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index e9ebc11e9cd9..5a1bef8ba30b 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import StrictBool, StrictInt, StrictStr @@ -44,7 +44,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_header_integer_boolean_string(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 """Test header parameter(s) # noqa: E501 @@ -78,7 +78,7 @@ def test_header_integer_boolean_string(self, integer_header : Optional[StrictInt raise ValueError(message) return self.test_header_integer_boolean_string_with_http_info(integer_header, boolean_header, string_header, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_header_integer_boolean_string_with_http_info(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test header parameter(s) # noqa: E501 diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index a2798c4d604a..99f144742ab1 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import StrictInt, StrictStr @@ -42,7 +42,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def tests_path_string_path_string_integer_path_integer(self, path_string : StrictStr, path_integer : StrictInt, **kwargs) -> str: # noqa: E501 """Test path parameter(s) # noqa: E501 @@ -74,7 +74,7 @@ def tests_path_string_path_string_integer_path_integer(self, path_string : Stric raise ValueError(message) return self.tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def tests_path_string_path_string_integer_path_integer_with_http_info(self, path_string : StrictStr, path_integer : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 """Test path parameter(s) # noqa: E501 diff --git a/samples/client/echo_api/python/openapi_client/api/query_api.py b/samples/client/echo_api/python/openapi_client/api/query_api.py index 09d55efd2f56..caca1968b164 100644 --- a/samples/client/echo_api/python/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python/openapi_client/api/query_api.py @@ -17,7 +17,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from datetime import date, datetime @@ -49,7 +49,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_enum_ref_string(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -79,7 +79,7 @@ def test_enum_ref_string(self, enum_ref_string_query : Optional[StringEnumRef] = raise ValueError(message) return self.test_enum_ref_string_with_http_info(enum_ref_string_query, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -189,7 +189,7 @@ def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[S collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_datetime_date_string(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -223,7 +223,7 @@ def test_query_datetime_date_string(self, datetime_query : Optional[datetime] = raise ValueError(message) return self.test_query_datetime_date_string_with_http_info(datetime_query, date_query, string_query, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_datetime_date_string_with_http_info(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -351,7 +351,7 @@ def test_query_datetime_date_string_with_http_info(self, datetime_query : Option collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_integer_boolean_string(self, integer_query : Optional[StrictInt] = None, boolean_query : Optional[StrictBool] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -385,7 +385,7 @@ def test_query_integer_boolean_string(self, integer_query : Optional[StrictInt] raise ValueError(message) return self.test_query_integer_boolean_string_with_http_info(integer_query, boolean_query, string_query, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_integer_boolean_string_with_http_info(self, integer_query : Optional[StrictInt] = None, boolean_query : Optional[StrictBool] = None, string_query : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -507,7 +507,7 @@ def test_query_integer_boolean_string_with_http_info(self, integer_query : Optio collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_style_deep_object_explode_true_object(self, query_object : Optional[Pet] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -537,7 +537,7 @@ def test_query_style_deep_object_explode_true_object(self, query_object : Option raise ValueError(message) return self.test_query_style_deep_object_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_style_deep_object_explode_true_object_with_http_info(self, query_object : Optional[Pet] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -647,7 +647,7 @@ def test_query_style_deep_object_explode_true_object_with_http_info(self, query_ collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_style_deep_object_explode_true_object_all_of(self, query_object : Optional[Any] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -677,7 +677,7 @@ def test_query_style_deep_object_explode_true_object_all_of(self, query_object : raise ValueError(message) return self.test_query_style_deep_object_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_style_deep_object_explode_true_object_all_of_with_http_info(self, query_object : Optional[Any] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -787,7 +787,7 @@ def test_query_style_deep_object_explode_true_object_all_of_with_http_info(self, collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_style_form_explode_true_array_string(self, query_object : Optional[TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -817,7 +817,7 @@ def test_query_style_form_explode_true_array_string(self, query_object : Optiona raise ValueError(message) return self.test_query_style_form_explode_true_array_string_with_http_info(query_object, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_style_form_explode_true_array_string_with_http_info(self, query_object : Optional[TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -927,7 +927,7 @@ def test_query_style_form_explode_true_array_string_with_http_info(self, query_o collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_style_form_explode_true_object(self, query_object : Optional[Pet] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -957,7 +957,7 @@ def test_query_style_form_explode_true_object(self, query_object : Optional[Pet] raise ValueError(message) return self.test_query_style_form_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_style_form_explode_true_object_with_http_info(self, query_object : Optional[Pet] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -1067,7 +1067,7 @@ def test_query_style_form_explode_true_object_with_http_info(self, query_object collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_style_form_explode_true_object_all_of(self, query_object : Optional[Any] = None, **kwargs) -> str: # noqa: E501 """Test query parameter(s) # noqa: E501 @@ -1097,7 +1097,7 @@ def test_query_style_form_explode_true_object_all_of(self, query_object : Option raise ValueError(message) return self.test_query_style_form_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_style_form_explode_true_object_all_of_with_http_info(self, query_object : Optional[Any] = None, **kwargs) -> ApiResponse: # noqa: E501 """Test query parameter(s) # noqa: E501 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 ea447caaa8e7..13b67878e2e0 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -30,14 +30,15 @@ class Bird(BaseModel): color: Optional[StrictStr] = None __properties = ["size", "color"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Bird: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> Bird: return None if not isinstance(obj, dict): - return Bird.parse_obj(obj) + return Bird.model_validate(obj) - _obj = Bird.parse_obj({ + _obj = Bird.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 fc4d2c6983a9..0d4cfdd54dcb 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -30,14 +30,15 @@ class Category(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Category: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> Category: return None if not isinstance(obj, dict): - return Category.parse_obj(obj) + return Category.model_validate(obj) - _obj = Category.parse_obj({ + _obj = Category.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 ae0c7e7595c5..14f2288d1c0a 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 @@ -33,14 +33,15 @@ class DataQuery(Query): var_date: Optional[datetime] = Field(default=None, description="A date", alias="date") __properties = ["id", "outcomes", "suffix", "text", "date"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> DataQuery: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -67,9 +68,9 @@ def from_dict(cls, obj: dict) -> DataQuery: return None if not isinstance(obj, dict): - return DataQuery.parse_obj(obj) + return DataQuery.model_validate(obj) - _obj = DataQuery.parse_obj({ + _obj = DataQuery.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 895349de2c46..e807e94e34c2 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 @@ -20,7 +20,7 @@ from typing import List, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from openapi_client.models.string_enum_ref import StringEnumRef class DefaultValue(BaseModel): @@ -37,7 +37,7 @@ class DefaultValue(BaseModel): string_nullable: Optional[StrictStr] = None __properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"] - @validator('array_string_enum_default') + @field_validator('array_string_enum_default') def array_string_enum_default_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -48,14 +48,15 @@ def array_string_enum_default_validate_enum(cls, value): raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -69,23 +70,23 @@ def from_json(cls, json_str: str) -> DefaultValue: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) # set to None if array_string_nullable (nullable) is None - # and __fields_set__ contains the field - if self.array_string_nullable is None and "array_string_nullable" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_string_nullable is None and "array_string_nullable" in self.model_fields_set: _dict['array_string_nullable'] = None # set to None if array_string_extension_nullable (nullable) is None - # and __fields_set__ contains the field - if self.array_string_extension_nullable is None and "array_string_extension_nullable" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_string_extension_nullable is None and "array_string_extension_nullable" in self.model_fields_set: _dict['array_string_extension_nullable'] = None # set to None if string_nullable (nullable) is None - # and __fields_set__ contains the field - if self.string_nullable is None and "string_nullable" in self.__fields_set__: + # and model_fields_set contains the field + if self.string_nullable is None and "string_nullable" in self.model_fields_set: _dict['string_nullable'] = None return _dict @@ -97,9 +98,9 @@ def from_dict(cls, obj: dict) -> DefaultValue: return None if not isinstance(obj, dict): - return DefaultValue.parse_obj(obj) + return DefaultValue.model_validate(obj) - _obj = DefaultValue.parse_obj({ + _obj = DefaultValue.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 e23550731d23..23a179ae2a8a 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 @@ -32,14 +32,15 @@ class NumberPropertiesOnly(BaseModel): double: Optional[Union[Annotated[float, Field(le=50.2, strict=True, ge=0.8)], Annotated[int, Field(le=50, strict=True, ge=1)]]] = None __properties = ["number", "double"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> NumberPropertiesOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> NumberPropertiesOnly: return None if not isinstance(obj, dict): - return NumberPropertiesOnly.parse_obj(obj) + return NumberPropertiesOnly.model_validate(obj) - _obj = NumberPropertiesOnly.parse_obj({ + _obj = NumberPropertiesOnly.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 3a955d0322ca..51b1d20275a3 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -20,7 +20,7 @@ from typing import List, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from openapi_client.models.category import Category from openapi_client.models.tag import Tag @@ -37,7 +37,7 @@ class Pet(BaseModel): status: Optional[StrictStr] = Field(default=None, description="pet status in the store") __properties = ["id", "name", "category", "photoUrls", "tags", "status"] - @validator('status') + @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -47,14 +47,15 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -68,7 +69,7 @@ def from_json(cls, json_str: str) -> Pet: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -91,9 +92,9 @@ def from_dict(cls, obj: dict) -> Pet: return None if not isinstance(obj, dict): - return Pet.parse_obj(obj) + return Pet.model_validate(obj) - _obj = Pet.parse_obj({ + _obj = Pet.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 ba6c8b09f21e..c96f723c99b7 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -20,7 +20,7 @@ from typing import List, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field class Query(BaseModel): @@ -31,7 +31,7 @@ class Query(BaseModel): outcomes: Optional[List[StrictStr]] = None __properties = ["id", "outcomes"] - @validator('outcomes') + @field_validator('outcomes') def outcomes_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -42,14 +42,15 @@ def outcomes_validate_enum(cls, value): raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -63,7 +64,7 @@ def from_json(cls, json_str: str) -> Query: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) 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 18e2db0c571f..5e456e33d229 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -30,14 +30,15 @@ class Tag(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Tag: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> Tag: return None if not isinstance(obj, dict): - return Tag.parse_obj(obj) + return Tag.model_validate(obj) - _obj = Tag.parse_obj({ + _obj = Tag.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 3ae2d2a2905c..c809f92c4944 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 @@ -32,14 +32,15 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod name: Optional[StrictStr] = None __properties = ["size", "color", "id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> TestQueryStyleDeepObjectExplodeTrueObjectAl def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQ return None if not isinstance(obj, dict): - return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj(obj) + return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate(obj) - _obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj({ + _obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.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 ebc1612f0384..1fef35695999 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 @@ -29,14 +29,15 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): values: Optional[List[StrictStr]] = None __properties = ["values"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> TestQueryStyleFormExplodeTrueArrayStringQue def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> TestQueryStyleFormExplodeTrueArrayStringQueryOb return None if not isinstance(obj, dict): - return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj(obj) + return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate(obj) - _obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj({ + _obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate({ "values": obj.get("values") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index 1b98cf6c66f9..7ba6e9979a41 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -42,7 +42,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def call_123_test_special_tags(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test special tags # noqa: E501 @@ -65,7 +65,7 @@ async def call_123_test_special_tags(self, client : Annotated[Client, Field(desc raise ValueError(message) return await self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def call_123_test_special_tags_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test special tags # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index 048cdf7d30ab..4adb84f0a259 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from petstore_api.models.foo_get_default_response import FooGetDefaultResponse @@ -40,7 +40,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def foo_get(self, **kwargs) -> FooGetDefaultResponse: # noqa: E501 """foo_get # noqa: E501 @@ -60,7 +60,7 @@ async def foo_get(self, **kwargs) -> FooGetDefaultResponse: # noqa: E501 raise ValueError(message) return await self.foo_get_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call async def foo_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """foo_get # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 01e9792aa338..31db62d60aee 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -16,13 +16,13 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated from datetime import date, datetime -from pydantic import StrictBool, StrictBytes, StrictInt, StrictStr, validator +from pydantic import StrictBool, StrictBytes, StrictInt, StrictStr, field_validator from typing import Any, Dict, List, Optional, Union @@ -57,7 +57,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def fake_any_type_request_body(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> None: # noqa: E501 """test any type request body # noqa: E501 @@ -79,7 +79,7 @@ async def fake_any_type_request_body(self, body : Optional[Dict[str, Any]] = Non raise ValueError(message) return await self.fake_any_type_request_body_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_any_type_request_body_with_http_info(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse: # noqa: E501 """test any type request body # noqa: E501 @@ -180,7 +180,7 @@ async def fake_any_type_request_body_with_http_info(self, body : Optional[Dict[s collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_enum_ref_query_parameter(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> None: # noqa: E501 """test enum reference query parameter # noqa: E501 @@ -202,7 +202,7 @@ async def fake_enum_ref_query_parameter(self, enum_ref : Annotated[Optional[Enum raise ValueError(message) return await self.fake_enum_ref_query_parameter_with_http_info(enum_ref, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_enum_ref_query_parameter_with_http_info(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> ApiResponse: # noqa: E501 """test enum reference query parameter # noqa: E501 @@ -296,7 +296,7 @@ async def fake_enum_ref_query_parameter_with_http_info(self, enum_ref : Annotate collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_health_get(self, **kwargs) -> HealthCheckResult: # noqa: E501 """Health check endpoint # noqa: E501 @@ -316,7 +316,7 @@ async def fake_health_get(self, **kwargs) -> HealthCheckResult: # noqa: E501 raise ValueError(message) return await self.fake_health_get_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Health check endpoint # noqa: E501 @@ -410,7 +410,7 @@ async def fake_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_http_signature_test(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> None: # noqa: E501 """test http signature authentication # noqa: E501 @@ -436,7 +436,7 @@ async def fake_http_signature_test(self, pet : Annotated[Pet, Field(description= raise ValueError(message) return await self.fake_http_signature_test_with_http_info(pet, query_1, header_1, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_http_signature_test_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> ApiResponse: # noqa: E501 """test http signature authentication # noqa: E501 @@ -549,7 +549,7 @@ async def fake_http_signature_test_with_http_info(self, pet : Annotated[Pet, Fie collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_outer_boolean_serialize(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> bool: # noqa: E501 """fake_outer_boolean_serialize # noqa: E501 @@ -572,7 +572,7 @@ async def fake_outer_boolean_serialize(self, body : Annotated[Optional[StrictBoo raise ValueError(message) return await self.fake_outer_boolean_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_outer_boolean_serialize_with_http_info(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_boolean_serialize # noqa: E501 @@ -680,7 +680,7 @@ async def fake_outer_boolean_serialize_with_http_info(self, body : Annotated[Opt collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_outer_composite_serialize(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> OuterComposite: # noqa: E501 """fake_outer_composite_serialize # noqa: E501 @@ -703,7 +703,7 @@ async def fake_outer_composite_serialize(self, outer_composite : Annotated[Optio raise ValueError(message) return await self.fake_outer_composite_serialize_with_http_info(outer_composite, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_outer_composite_serialize_with_http_info(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_composite_serialize # noqa: E501 @@ -811,7 +811,7 @@ async def fake_outer_composite_serialize_with_http_info(self, outer_composite : collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_outer_number_serialize(self, body : Annotated[Optional[float], Field(description="Input number as post body")] = None, **kwargs) -> float: # noqa: E501 """fake_outer_number_serialize # noqa: E501 @@ -834,7 +834,7 @@ async def fake_outer_number_serialize(self, body : Annotated[Optional[float], Fi raise ValueError(message) return await self.fake_outer_number_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_outer_number_serialize_with_http_info(self, body : Annotated[Optional[float], Field(description="Input number as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_number_serialize # noqa: E501 @@ -942,7 +942,7 @@ async def fake_outer_number_serialize_with_http_info(self, body : Annotated[Opti collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_outer_string_serialize(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> str: # noqa: E501 """fake_outer_string_serialize # noqa: E501 @@ -965,7 +965,7 @@ async def fake_outer_string_serialize(self, body : Annotated[Optional[StrictStr] raise ValueError(message) return await self.fake_outer_string_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_outer_string_serialize_with_http_info(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_string_serialize # noqa: E501 @@ -1073,7 +1073,7 @@ async def fake_outer_string_serialize_with_http_info(self, body : Annotated[Opti collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_property_enum_integer_serialize(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(description="Input enum (int) as post body")], **kwargs) -> OuterObjectWithEnumProperty: # noqa: E501 """fake_property_enum_integer_serialize # noqa: E501 @@ -1096,7 +1096,7 @@ async def fake_property_enum_integer_serialize(self, outer_object_with_enum_prop raise ValueError(message) return await self.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(description="Input enum (int) as post body")], **kwargs) -> ApiResponse: # noqa: E501 """fake_property_enum_integer_serialize # noqa: E501 @@ -1204,7 +1204,7 @@ async def fake_property_enum_integer_serialize_with_http_info(self, outer_object collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_return_list_of_objects(self, **kwargs) -> List[List[Tag]]: # noqa: E501 """test returning list of objects # noqa: E501 @@ -1224,7 +1224,7 @@ async def fake_return_list_of_objects(self, **kwargs) -> List[List[Tag]]: # noq raise ValueError(message) return await self.fake_return_list_of_objects_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_return_list_of_objects_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """test returning list of objects # noqa: E501 @@ -1318,7 +1318,7 @@ async def fake_return_list_of_objects_with_http_info(self, **kwargs) -> ApiRespo collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(description="uuid example")], **kwargs) -> None: # noqa: E501 """test uuid example # noqa: E501 @@ -1340,7 +1340,7 @@ async def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(desc raise ValueError(message) return await self.fake_uuid_example_with_http_info(uuid_example, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def fake_uuid_example_with_http_info(self, uuid_example : Annotated[StrictStr, Field(description="uuid example")], **kwargs) -> ApiResponse: # noqa: E501 """test uuid example # noqa: E501 @@ -1434,7 +1434,7 @@ async def fake_uuid_example_with_http_info(self, uuid_example : Annotated[Strict collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_body_with_binary(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="image to upload")], **kwargs) -> None: # noqa: E501 """test_body_with_binary # noqa: E501 @@ -1457,7 +1457,7 @@ async def test_body_with_binary(self, body : Annotated[Optional[Union[StrictByte raise ValueError(message) return await self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_body_with_binary_with_http_info(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="image to upload")], **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_binary # noqa: E501 @@ -1564,7 +1564,7 @@ async def test_body_with_binary_with_http_info(self, body : Annotated[Optional[U collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_body_with_file_schema(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> None: # noqa: E501 """test_body_with_file_schema # noqa: E501 @@ -1587,7 +1587,7 @@ async def test_body_with_file_schema(self, file_schema_test_class : FileSchemaTe raise ValueError(message) return await self.test_body_with_file_schema_with_http_info(file_schema_test_class, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_body_with_file_schema_with_http_info(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_file_schema # noqa: E501 @@ -1689,7 +1689,7 @@ async def test_body_with_file_schema_with_http_info(self, file_schema_test_class collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_body_with_query_params(self, query : StrictStr, user : User, **kwargs) -> None: # noqa: E501 """test_body_with_query_params # noqa: E501 @@ -1713,7 +1713,7 @@ async def test_body_with_query_params(self, query : StrictStr, user : User, **kw raise ValueError(message) return await self.test_body_with_query_params_with_http_info(query, user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_body_with_query_params_with_http_info(self, query : StrictStr, user : User, **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_query_params # noqa: E501 @@ -1820,7 +1820,7 @@ async def test_body_with_query_params_with_http_info(self, query : StrictStr, us collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_client_model(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test \"client\" model # noqa: E501 @@ -1843,7 +1843,7 @@ async def test_client_model(self, client : Annotated[Client, Field(description=" raise ValueError(message) return await self.test_client_model_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_client_model_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test \"client\" model # noqa: E501 @@ -1951,7 +1951,7 @@ async def test_client_model_with_http_info(self, client : Annotated[Client, Fiel collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_date_time_query_parameter(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> None: # noqa: E501 """test_date_time_query_parameter # noqa: E501 @@ -1975,7 +1975,7 @@ async def test_date_time_query_parameter(self, date_time_query : datetime, str_q raise ValueError(message) return await self.test_date_time_query_parameter_with_http_info(date_time_query, str_query, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_date_time_query_parameter_with_http_info(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 """test_date_time_query_parameter # noqa: E501 @@ -2078,7 +2078,7 @@ async def test_date_time_query_parameter_with_http_info(self, date_time_query : collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_endpoint_parameters(self, number : Annotated[float, Field(le=543.2, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(strict=True, max_length=64)]]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2129,7 +2129,7 @@ async def test_endpoint_parameters(self, number : Annotated[float, Field(le=543. raise ValueError(message) return await self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, byte_with_max_length, var_date, date_time, password, param_callback, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_endpoint_parameters_with_http_info(self, number : Annotated[float, Field(le=543.2, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(strict=True, max_length=64)]]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2315,7 +2315,7 @@ async def test_endpoint_parameters_with_http_info(self, number : Annotated[float collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_group_parameters(self, required_string_group : Annotated[StrictInt, Field(description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 @@ -2348,7 +2348,7 @@ async def test_group_parameters(self, required_string_group : Annotated[StrictIn raise ValueError(message) return await self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, string_group, boolean_group, int64_group, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_group_parameters_with_http_info(self, required_string_group : Annotated[StrictInt, Field(description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 @@ -2473,7 +2473,7 @@ async def test_group_parameters_with_http_info(self, required_string_group : Ann collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_inline_additional_properties(self, request_body : Annotated[Dict[str, StrictStr], Field(description="request body")], **kwargs) -> None: # noqa: E501 """test inline additionalProperties # noqa: E501 @@ -2496,7 +2496,7 @@ async def test_inline_additional_properties(self, request_body : Annotated[Dict[ raise ValueError(message) return await self.test_inline_additional_properties_with_http_info(request_body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_inline_additional_properties_with_http_info(self, request_body : Annotated[Dict[str, StrictStr], Field(description="request body")], **kwargs) -> ApiResponse: # noqa: E501 """test inline additionalProperties # noqa: E501 @@ -2598,7 +2598,7 @@ async def test_inline_additional_properties_with_http_info(self, request_body : collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_inline_freeform_additional_properties(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> None: # noqa: E501 """test inline free-form additionalProperties # noqa: E501 @@ -2621,7 +2621,7 @@ async def test_inline_freeform_additional_properties(self, test_inline_freeform_ raise ValueError(message) return await self.test_inline_freeform_additional_properties_with_http_info(test_inline_freeform_additional_properties_request, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_inline_freeform_additional_properties_with_http_info(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> ApiResponse: # noqa: E501 """test inline free-form additionalProperties # noqa: E501 @@ -2723,7 +2723,7 @@ async def test_inline_freeform_additional_properties_with_http_info(self, test_i collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_json_form_data(self, param : Annotated[StrictStr, Field(description="field1")], param2 : Annotated[StrictStr, Field(description="field2")], **kwargs) -> None: # noqa: E501 """test json serialization of form data # noqa: E501 @@ -2748,7 +2748,7 @@ async def test_json_form_data(self, param : Annotated[StrictStr, Field(descripti raise ValueError(message) return await self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, Field(description="field1")], param2 : Annotated[StrictStr, Field(description="field2")], **kwargs) -> ApiResponse: # noqa: E501 """test json serialization of form data # noqa: E501 @@ -2856,7 +2856,7 @@ async def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def test_query_parameter_collection_format(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> None: # noqa: E501 """test_query_parameter_collection_format # noqa: E501 @@ -2891,7 +2891,7 @@ async def test_query_parameter_collection_format(self, pipe : List[StrictStr], i raise ValueError(message) return await self.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_query_parameter_collection_format_with_http_info(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501 """test_query_parameter_collection_format # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index bf28c7013068..1fc4e4426295 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -42,7 +42,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def test_classname(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test class name in snake case # noqa: E501 @@ -65,7 +65,7 @@ async def test_classname(self, client : Annotated[Client, Field(description="cli raise ValueError(message) return await self.test_classname_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def test_classname_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test class name in snake case # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 6619d616dd42..143ae4858318 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -16,11 +16,11 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated -from pydantic import StrictBytes, StrictInt, StrictStr, validator +from pydantic import StrictBytes, StrictInt, StrictStr, field_validator from typing import List, Optional, Union @@ -47,7 +47,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def add_pet(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 """Add a new pet to the store # noqa: E501 @@ -70,7 +70,7 @@ async def add_pet(self, pet : Annotated[Pet, Field(description="Pet object that raise ValueError(message) return await self.add_pet_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def add_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 """Add a new pet to the store # noqa: E501 @@ -172,7 +172,7 @@ async def add_pet_with_http_info(self, pet : Annotated[Pet, Field(description="P collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def delete_pet(self, pet_id : Annotated[StrictInt, Field(description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 """Deletes a pet # noqa: E501 @@ -197,7 +197,7 @@ async def delete_pet(self, pet_id : Annotated[StrictInt, Field(description="Pet raise ValueError(message) return await self.delete_pet_with_http_info(pet_id, api_key, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def delete_pet_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Deletes a pet # noqa: E501 @@ -298,7 +298,7 @@ async def delete_pet_with_http_info(self, pet_id : Annotated[StrictInt, Field(de collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def find_pets_by_status(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> List[Pet]: # noqa: E501 """Finds Pets by status # noqa: E501 @@ -321,7 +321,7 @@ async def find_pets_by_status(self, status : Annotated[List[StrictStr], Field(de raise ValueError(message) return await self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def find_pets_by_status_with_http_info(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> ApiResponse: # noqa: E501 """Finds Pets by status # noqa: E501 @@ -424,7 +424,7 @@ async def find_pets_by_status_with_http_info(self, status : Annotated[List[Stric collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def find_pets_by_tags(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> List[Pet]: # noqa: E501 """(Deprecated) Finds Pets by tags # noqa: E501 @@ -447,7 +447,7 @@ async def find_pets_by_tags(self, tags : Annotated[List[StrictStr], Field(descri raise ValueError(message) return await self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def find_pets_by_tags_with_http_info(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> ApiResponse: # noqa: E501 """(Deprecated) Finds Pets by tags # noqa: E501 @@ -552,7 +552,7 @@ async def find_pets_by_tags_with_http_info(self, tags : Annotated[List[StrictStr collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to return")], **kwargs) -> Pet: # noqa: E501 """Find pet by ID # noqa: E501 @@ -575,7 +575,7 @@ async def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(description="I raise ValueError(message) return await self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to return")], **kwargs) -> ApiResponse: # noqa: E501 """Find pet by ID # noqa: E501 @@ -678,7 +678,7 @@ async def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def update_pet(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 """Update an existing pet # noqa: E501 @@ -701,7 +701,7 @@ async def update_pet(self, pet : Annotated[Pet, Field(description="Pet object th raise ValueError(message) return await self.update_pet_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def update_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 """Update an existing pet # noqa: E501 @@ -803,7 +803,7 @@ async def update_pet_with_http_info(self, pet : Annotated[Pet, Field(description collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def update_pet_with_form(self, pet_id : Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> None: # noqa: E501 """Updates a pet in the store with form data # noqa: E501 @@ -830,7 +830,7 @@ async def update_pet_with_form(self, pet_id : Annotated[StrictInt, Field(descrip raise ValueError(message) return await self.update_pet_with_form_with_http_info(pet_id, name, status, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def update_pet_with_form_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Updates a pet in the store with form data # noqa: E501 @@ -944,7 +944,7 @@ async def update_pet_with_form_with_http_info(self, pet_id : Annotated[StrictInt collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def upload_file(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image # noqa: E501 @@ -971,7 +971,7 @@ async def upload_file(self, pet_id : Annotated[StrictInt, Field(description="ID raise ValueError(message) return await self.upload_file_with_http_info(pet_id, additional_metadata, file, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def upload_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image # noqa: E501 @@ -1091,7 +1091,7 @@ async def upload_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(d collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def upload_file_with_required_file(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image (required) # noqa: E501 @@ -1118,7 +1118,7 @@ async def upload_file_with_required_file(self, pet_id : Annotated[StrictInt, Fie raise ValueError(message) return await self.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def upload_file_with_required_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image (required) # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index c25fa5f697b7..dd992c9f013b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -46,7 +46,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def delete_order(self, order_id : Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")], **kwargs) -> None: # noqa: E501 """Delete purchase order by ID # noqa: E501 @@ -69,7 +69,7 @@ async def delete_order(self, order_id : Annotated[StrictStr, Field(description=" raise ValueError(message) return await self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def delete_order_with_http_info(self, order_id : Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 """Delete purchase order by ID # noqa: E501 @@ -164,7 +164,7 @@ async def delete_order_with_http_info(self, order_id : Annotated[StrictStr, Fiel collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def get_inventory(self, **kwargs) -> Dict[str, int]: # noqa: E501 """Returns pet inventories by status # noqa: E501 @@ -185,7 +185,7 @@ async def get_inventory(self, **kwargs) -> Dict[str, int]: # noqa: E501 raise ValueError(message) return await self.get_inventory_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call async def get_inventory_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Returns pet inventories by status # noqa: E501 @@ -280,7 +280,7 @@ async def get_inventory_with_http_info(self, **kwargs) -> ApiResponse: # noqa: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def get_order_by_id(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> Order: # noqa: E501 """Find purchase order by ID # noqa: E501 @@ -303,7 +303,7 @@ async def get_order_by_id(self, order_id : Annotated[int, Field(le=5, strict=Tru raise ValueError(message) return await self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def get_order_by_id_with_http_info(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> ApiResponse: # noqa: E501 """Find purchase order by ID # noqa: E501 @@ -406,7 +406,7 @@ async def get_order_by_id_with_http_info(self, order_id : Annotated[int, Field(l collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def place_order(self, order : Annotated[Order, Field(description="order placed for purchasing the pet")], **kwargs) -> Order: # noqa: E501 """Place an order for a pet # noqa: E501 @@ -429,7 +429,7 @@ async def place_order(self, order : Annotated[Order, Field(description="order pl raise ValueError(message) return await self.place_order_with_http_info(order, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def place_order_with_http_info(self, order : Annotated[Order, Field(description="order placed for purchasing the pet")], **kwargs) -> ApiResponse: # noqa: E501 """Place an order for a pet # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index fa23d5a8fd72..00e32e0663e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -46,7 +46,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call async def create_user(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> None: # noqa: E501 """Create user # noqa: E501 @@ -69,7 +69,7 @@ async def create_user(self, user : Annotated[User, Field(description="Created us raise ValueError(message) return await self.create_user_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def create_user_with_http_info(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> ApiResponse: # noqa: E501 """Create user # noqa: E501 @@ -186,7 +186,7 @@ async def create_user_with_http_info(self, user : Annotated[User, Field(descript collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def create_users_with_array_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -209,7 +209,7 @@ async def create_users_with_array_input(self, user : Annotated[List[User], Field raise ValueError(message) return await self.create_users_with_array_input_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def create_users_with_array_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -311,7 +311,7 @@ async def create_users_with_array_input_with_http_info(self, user : Annotated[Li collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def create_users_with_list_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -334,7 +334,7 @@ async def create_users_with_list_input(self, user : Annotated[List[User], Field( raise ValueError(message) return await self.create_users_with_list_input_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def create_users_with_list_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -436,7 +436,7 @@ async def create_users_with_list_input_with_http_info(self, user : Annotated[Lis collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def delete_user(self, username : Annotated[StrictStr, Field(description="The name that needs to be deleted")], **kwargs) -> None: # noqa: E501 """Delete user # noqa: E501 @@ -459,7 +459,7 @@ async def delete_user(self, username : Annotated[StrictStr, Field(description="T raise ValueError(message) return await self.delete_user_with_http_info(username, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def delete_user_with_http_info(self, username : Annotated[StrictStr, Field(description="The name that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 """Delete user # noqa: E501 @@ -554,7 +554,7 @@ async def delete_user_with_http_info(self, username : Annotated[StrictStr, Field collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def get_user_by_name(self, username : Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> User: # noqa: E501 """Get user by user name # noqa: E501 @@ -577,7 +577,7 @@ async def get_user_by_name(self, username : Annotated[StrictStr, Field(descripti raise ValueError(message) return await self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def get_user_by_name_with_http_info(self, username : Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> ApiResponse: # noqa: E501 """Get user by user name # noqa: E501 @@ -680,7 +680,7 @@ async def get_user_by_name_with_http_info(self, username : Annotated[StrictStr, collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def login_user(self, username : Annotated[StrictStr, Field(description="The user name for login")], password : Annotated[StrictStr, Field(description="The password for login in clear text")], **kwargs) -> str: # noqa: E501 """Logs user into the system # noqa: E501 @@ -705,7 +705,7 @@ async def login_user(self, username : Annotated[StrictStr, Field(description="Th raise ValueError(message) return await self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def login_user_with_http_info(self, username : Annotated[StrictStr, Field(description="The user name for login")], password : Annotated[StrictStr, Field(description="The password for login in clear text")], **kwargs) -> ApiResponse: # noqa: E501 """Logs user into the system # noqa: E501 @@ -813,7 +813,7 @@ async def login_user_with_http_info(self, username : Annotated[StrictStr, Field( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def logout_user(self, **kwargs) -> None: # noqa: E501 """Logs out current logged in user session # noqa: E501 @@ -834,7 +834,7 @@ async def logout_user(self, **kwargs) -> None: # noqa: E501 raise ValueError(message) return await self.logout_user_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call async def logout_user_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Logs out current logged in user session # noqa: E501 @@ -923,7 +923,7 @@ async def logout_user_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E5 collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call async def update_user(self, username : Annotated[StrictStr, Field(description="name that need to be deleted")], user : Annotated[User, Field(description="Updated user object")], **kwargs) -> None: # noqa: E501 """Updated user # noqa: E501 @@ -948,7 +948,7 @@ async def update_user(self, username : Annotated[StrictStr, Field(description="n raise ValueError(message) return await self.update_user_with_http_info(username, user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call async def update_user_with_http_info(self, username : Annotated[StrictStr, Field(description="name that need to be deleted")], user : Annotated[User, Field(description="Updated user object")], **kwargs) -> ApiResponse: # noqa: E501 """Updated user # noqa: E501 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 9c3fc032c1ba..434439f1769a 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesAnyType(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType: return None if not isinstance(obj, dict): - return AdditionalPropertiesAnyType.parse_obj(obj) + return AdditionalPropertiesAnyType.model_validate(obj) - _obj = AdditionalPropertiesAnyType.parse_obj({ + _obj = AdditionalPropertiesAnyType.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 960d5452f786..86f52278aa18 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesClass(BaseModel): map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None __properties = ["map_property", "map_of_map_property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: return None if not isinstance(obj, dict): - return AdditionalPropertiesClass.parse_obj(obj) + return AdditionalPropertiesClass.model_validate(obj) - _obj = AdditionalPropertiesClass.parse_obj({ + _obj = AdditionalPropertiesClass.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 566643e80874..e05cd9a4752f 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesObject: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesObject: return None if not isinstance(obj, dict): - return AdditionalPropertiesObject.parse_obj(obj) + return AdditionalPropertiesObject.model_validate(obj) - _obj = AdditionalPropertiesObject.parse_obj({ + _obj = AdditionalPropertiesObject.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 79e6c925a304..10e6602941b6 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesWithDescriptionOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesWithDescriptionOnly: return None if not isinstance(obj, dict): - return AdditionalPropertiesWithDescriptionOnly.parse_obj(obj) + return AdditionalPropertiesWithDescriptionOnly.model_validate(obj) - _obj = AdditionalPropertiesWithDescriptionOnly.parse_obj({ + _obj = AdditionalPropertiesWithDescriptionOnly.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 285f28670a1f..302f89173e4c 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 @@ -31,14 +31,15 @@ class AllOfWithSingleRef(BaseModel): single_ref_type: Optional[SingleRefType] = Field(default=None, alias="SingleRefType") __properties = ["username", "SingleRefType"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> AllOfWithSingleRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -65,9 +66,9 @@ def from_dict(cls, obj: dict) -> AllOfWithSingleRef: return None if not isinstance(obj, dict): - return AllOfWithSingleRef.parse_obj(obj) + return AllOfWithSingleRef.model_validate(obj) - _obj = AllOfWithSingleRef.parse_obj({ + _obj = AllOfWithSingleRef.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 4f62093ac2cb..33501c52ed0d 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 @@ -30,10 +30,11 @@ class Animal(BaseModel): color: Optional[StrictStr] = 'red' __properties = ["className", "color"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + # JSON field name that stores the object type __discriminator_property_name = 'className' @@ -55,7 +56,7 @@ def get_discriminator_value(cls, obj: dict) -> str: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -69,7 +70,7 @@ def from_json(cls, json_str: str) -> Union(Cat, Dog): def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) 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 397956daa536..23097a497506 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -34,9 +34,9 @@ class AnyOfColor(BaseModel): """ # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.") + anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") + anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") # data type: str anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") if TYPE_CHECKING: @@ -45,8 +45,9 @@ class AnyOfColor(BaseModel): actual_instance: Any = None any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } def __init__(self, *args, **kwargs) -> None: if args: @@ -58,9 +59,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.construct() + instance = AnyOfColor.model_construct() error_messages = [] # validate data type: List[int] try: @@ -93,7 +94,7 @@ def from_dict(cls, obj: dict) -> AnyOfColor: @classmethod def from_json(cls, json_str: str) -> AnyOfColor: """Returns the object represented by the json string""" - instance = AnyOfColor.construct() + instance = AnyOfColor.model_construct() error_messages = [] # deserialize data into List[int] try: @@ -153,6 +154,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 174c3af2554a..00369b878bd3 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -43,8 +43,9 @@ class AnyOfPig(BaseModel): actual_instance: Any = None any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } def __init__(self, *args, **kwargs) -> None: if args: @@ -56,9 +57,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.construct() + instance = AnyOfPig.model_construct() error_messages = [] # validate data type: BasquePig if not isinstance(v, BasquePig): @@ -85,7 +86,7 @@ def from_dict(cls, obj: dict) -> AnyOfPig: @classmethod def from_json(cls, json_str: str) -> AnyOfPig: """Returns the object represented by the json string""" - instance = AnyOfPig.construct() + instance = AnyOfPig.model_construct() error_messages = [] # anyof_schema_1_validator: Optional[BasquePig] = None try: @@ -130,6 +131,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 cd441f02a122..875a41e2aedb 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 @@ -30,14 +30,15 @@ class ApiResponse(BaseModel): message: Optional[StrictStr] = None __properties = ["code", "type", "message"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ApiResponse: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> ApiResponse: return None if not isinstance(obj, dict): - return ApiResponse.parse_obj(obj) + return ApiResponse.model_validate(obj) - _obj = ApiResponse.parse_obj({ + _obj = ApiResponse.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 c2fe6a0f0a4c..d798ac121c29 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 @@ -29,14 +29,15 @@ class ArrayOfArrayOfModel(BaseModel): another_property: Optional[List[List[Tag]]] = None __properties = ["another_property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ArrayOfArrayOfModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -72,9 +73,9 @@ def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: return None if not isinstance(obj, dict): - return ArrayOfArrayOfModel.parse_obj(obj) + return ArrayOfArrayOfModel.model_validate(obj) - _obj = ArrayOfArrayOfModel.parse_obj({ + _obj = ArrayOfArrayOfModel.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 61e443b2b9c5..7b25d1d101a5 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 @@ -29,14 +29,15 @@ class ArrayOfArrayOfNumberOnly(BaseModel): array_array_number: Optional[List[List[float]]] = Field(default=None, alias="ArrayArrayNumber") __properties = ["ArrayArrayNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ArrayOfArrayOfNumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> ArrayOfArrayOfNumberOnly: return None if not isinstance(obj, dict): - return ArrayOfArrayOfNumberOnly.parse_obj(obj) + return ArrayOfArrayOfNumberOnly.model_validate(obj) - _obj = ArrayOfArrayOfNumberOnly.parse_obj({ + _obj = ArrayOfArrayOfNumberOnly.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 4a77818138e5..d4ba3bd6da14 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 @@ -29,14 +29,15 @@ class ArrayOfNumberOnly(BaseModel): array_number: Optional[List[float]] = Field(default=None, alias="ArrayNumber") __properties = ["ArrayNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ArrayOfNumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> ArrayOfNumberOnly: return None if not isinstance(obj, dict): - return ArrayOfNumberOnly.parse_obj(obj) + return ArrayOfNumberOnly.model_validate(obj) - _obj = ArrayOfNumberOnly.parse_obj({ + _obj = ArrayOfNumberOnly.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 b1d86e8ab5c3..c195a37415fb 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 @@ -28,19 +28,20 @@ class ArrayTest(BaseModel): """ ArrayTest """ - array_of_string: Optional[Annotated[List[StrictStr], Field(min_items=0, max_items=3)]] = None + array_of_string: Optional[Annotated[List[StrictStr], Field(min_length=0, max_length=3)]] = None array_array_of_integer: Optional[List[List[StrictInt]]] = None array_array_of_model: Optional[List[List[ReadOnlyFirst]]] = None __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> ArrayTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -76,9 +77,9 @@ def from_dict(cls, obj: dict) -> ArrayTest: return None if not isinstance(obj, dict): - return ArrayTest.parse_obj(obj) + return ArrayTest.model_validate(obj) - _obj = ArrayTest.parse_obj({ + _obj = ArrayTest.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 5e644b98daf7..698016f3faa2 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 @@ -30,14 +30,15 @@ class BasquePig(BaseModel): color: StrictStr __properties = ["className", "color"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> BasquePig: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> BasquePig: return None if not isinstance(obj, dict): - return BasquePig.parse_obj(obj) + return BasquePig.model_validate(obj) - _obj = BasquePig.parse_obj({ + _obj = BasquePig.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 b09b8886badb..dcd0d77e7e12 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 @@ -34,14 +34,15 @@ class Capitalization(BaseModel): att_name: Optional[StrictStr] = Field(default=None, description="Name of the pet ", alias="ATT_NAME") __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -55,7 +56,7 @@ def from_json(cls, json_str: str) -> Capitalization: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -68,9 +69,9 @@ def from_dict(cls, obj: dict) -> Capitalization: return None if not isinstance(obj, dict): - return Capitalization.parse_obj(obj) + return Capitalization.model_validate(obj) - _obj = Capitalization.parse_obj({ + _obj = Capitalization.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 31c055907f9e..c716c253a479 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 @@ -29,14 +29,15 @@ class Cat(Animal): declawed: Optional[StrictBool] = None __properties = ["className", "color", "declawed"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Cat: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> Cat: return None if not isinstance(obj, dict): - return Cat.parse_obj(obj) + return Cat.model_validate(obj) - _obj = Cat.parse_obj({ + _obj = Cat.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 2d1a5acc762d..861e6e9ee073 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 @@ -29,14 +29,15 @@ class Category(BaseModel): name: StrictStr __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Category: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> Category: return None if not isinstance(obj, dict): - return Category.parse_obj(obj) + return Category.model_validate(obj) - _obj = Category.parse_obj({ + _obj = Category.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 806f03b7698a..920a3e8135e7 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 @@ -29,14 +29,15 @@ class CircularReferenceModel(BaseModel): nested: Optional[FirstRef] = None __properties = ["size", "nested"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> CircularReferenceModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> CircularReferenceModel: return None if not isinstance(obj, dict): - return CircularReferenceModel.parse_obj(obj) + return CircularReferenceModel.model_validate(obj) - _obj = CircularReferenceModel.parse_obj({ + _obj = CircularReferenceModel.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 a6ef8617c7cb..c340fd7de00e 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 @@ -29,14 +29,15 @@ class ClassModel(BaseModel): var_class: Optional[StrictStr] = Field(default=None, alias="_class") __properties = ["_class"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ClassModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> ClassModel: return None if not isinstance(obj, dict): - return ClassModel.parse_obj(obj) + return ClassModel.model_validate(obj) - _obj = ClassModel.parse_obj({ + _obj = ClassModel.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 669f070d32f4..1f03d4ffb57f 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 @@ -28,14 +28,15 @@ class Client(BaseModel): client: Optional[StrictStr] = None __properties = ["client"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -49,7 +50,7 @@ def from_json(cls, json_str: str) -> Client: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -62,9 +63,9 @@ def from_dict(cls, obj: dict) -> Client: return None if not isinstance(obj, dict): - return Client.parse_obj(obj) + return Client.model_validate(obj) - _obj = Client.parse_obj({ + _obj = Client.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 d6b2ab8d8d76..2fdc7e8805cf 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -33,16 +33,18 @@ class Color(BaseModel): RGB array, RGBA array, or hex string. """ # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.") + oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") + oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") # data type: str oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: List[str] = Literal[COLOR_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["List[int]", "str"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -54,12 +56,12 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): if v is None: return v - instance = Color.construct() + instance = Color.model_construct() error_messages = [] match = 0 # validate data type: List[int] @@ -96,7 +98,7 @@ def from_dict(cls, obj: dict) -> Color: @classmethod def from_json(cls, json_str: str) -> Color: """Returns the object represented by the json string""" - instance = Color.construct() + instance = Color.model_construct() if json_str is None: return instance @@ -165,6 +167,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 ebeb3a8d4890..269294aa24ee 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 @@ -30,14 +30,15 @@ class Creature(BaseModel): type: StrictStr __properties = ["info", "type"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Creature: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -67,9 +68,9 @@ def from_dict(cls, obj: dict) -> Creature: return None if not isinstance(obj, dict): - return Creature.parse_obj(obj) + return Creature.model_validate(obj) - _obj = Creature.parse_obj({ + _obj = Creature.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 e3430a519baa..fabe153f31bd 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 @@ -28,14 +28,15 @@ class CreatureInfo(BaseModel): name: StrictStr __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -49,7 +50,7 @@ def from_json(cls, json_str: str) -> CreatureInfo: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -62,9 +63,9 @@ def from_dict(cls, obj: dict) -> CreatureInfo: return None if not isinstance(obj, dict): - return CreatureInfo.parse_obj(obj) + return CreatureInfo.model_validate(obj) - _obj = CreatureInfo.parse_obj({ + _obj = CreatureInfo.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 b481fb48b817..f1bb9dc52184 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 @@ -30,14 +30,15 @@ class DanishPig(BaseModel): size: StrictInt __properties = ["className", "size"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> DanishPig: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> DanishPig: return None if not isinstance(obj, dict): - return DanishPig.parse_obj(obj) + return DanishPig.model_validate(obj) - _obj = DanishPig.parse_obj({ + _obj = DanishPig.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 0817078bb4a4..d7689114dc04 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 @@ -28,14 +28,15 @@ class DeprecatedObject(BaseModel): name: Optional[StrictStr] = None __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -49,7 +50,7 @@ def from_json(cls, json_str: str) -> DeprecatedObject: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -62,9 +63,9 @@ def from_dict(cls, obj: dict) -> DeprecatedObject: return None if not isinstance(obj, dict): - return DeprecatedObject.parse_obj(obj) + return DeprecatedObject.model_validate(obj) - _obj = DeprecatedObject.parse_obj({ + _obj = DeprecatedObject.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 904f1f69eab0..ca35796fb144 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 @@ -29,14 +29,15 @@ class Dog(Animal): breed: Optional[StrictStr] = None __properties = ["className", "color", "breed"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Dog: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> Dog: return None if not isinstance(obj, dict): - return Dog.parse_obj(obj) + return Dog.model_validate(obj) - _obj = Dog.parse_obj({ + _obj = Dog.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 a1340d266bc3..65765b6922d9 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 @@ -29,14 +29,15 @@ class DummyModel(BaseModel): self_ref: Optional[SelfReferenceModel] = None __properties = ["category", "self_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> DummyModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> DummyModel: return None if not isinstance(obj, dict): - return DummyModel.parse_obj(obj) + return DummyModel.model_validate(obj) - _obj = DummyModel.parse_obj({ + _obj = DummyModel.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 d8d163362df6..161fe46cc112 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 @@ -19,7 +19,7 @@ from typing import List, Optional -from pydantic import BaseModel, StrictStr, validator +from pydantic import BaseModel, StrictStr, field_validator class EnumArrays(BaseModel): """ @@ -29,7 +29,7 @@ class EnumArrays(BaseModel): array_enum: Optional[List[StrictStr]] = None __properties = ["just_symbol", "array_enum"] - @validator('just_symbol') + @field_validator('just_symbol') def just_symbol_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -39,7 +39,7 @@ def just_symbol_validate_enum(cls, value): raise ValueError("must be one of enum values ('>=', '$')") return value - @validator('array_enum') + @field_validator('array_enum') def array_enum_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -50,14 +50,15 @@ def array_enum_validate_enum(cls, value): raise ValueError("each list item must be one of ('fish', 'crab')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -71,7 +72,7 @@ def from_json(cls, json_str: str) -> EnumArrays: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -84,9 +85,9 @@ def from_dict(cls, obj: dict) -> EnumArrays: return None if not isinstance(obj, dict): - return EnumArrays.parse_obj(obj) + return EnumArrays.model_validate(obj) - _obj = EnumArrays.parse_obj({ + _obj = EnumArrays.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_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 1fe38fd8773f..347a39e802a3 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 @@ -19,7 +19,7 @@ from typing import Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue @@ -41,7 +41,7 @@ class EnumTest(BaseModel): outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(default=None, alias="outerEnumIntegerDefaultValue") __properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"] - @validator('enum_string') + @field_validator('enum_string') def enum_string_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -51,14 +51,14 @@ def enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value - @validator('enum_string_required') + @field_validator('enum_string_required') def enum_string_required_validate_enum(cls, value): """Validates the enum""" if value not in ('UPPER', 'lower', ''): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value - @validator('enum_integer_default') + @field_validator('enum_integer_default') def enum_integer_default_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -68,7 +68,7 @@ def enum_integer_default_validate_enum(cls, value): raise ValueError("must be one of enum values (1, 5, 14)") return value - @validator('enum_integer') + @field_validator('enum_integer') def enum_integer_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -78,7 +78,7 @@ def enum_integer_validate_enum(cls, value): raise ValueError("must be one of enum values (1, -1)") return value - @validator('enum_number') + @field_validator('enum_number') def enum_number_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -88,14 +88,15 @@ def enum_number_validate_enum(cls, value): raise ValueError("must be one of enum values (1.1, -1.2)") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -109,13 +110,13 @@ def from_json(cls, json_str: str) -> EnumTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) # set to None if outer_enum (nullable) is None - # and __fields_set__ contains the field - if self.outer_enum is None and "outer_enum" in self.__fields_set__: + # and model_fields_set contains the field + if self.outer_enum is None and "outer_enum" in self.model_fields_set: _dict['outerEnum'] = None return _dict @@ -127,9 +128,9 @@ def from_dict(cls, obj: dict) -> EnumTest: return None if not isinstance(obj, dict): - return EnumTest.parse_obj(obj) + return EnumTest.model_validate(obj) - _obj = EnumTest.parse_obj({ + _obj = EnumTest.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 4bd46a8359cf..4db5067c90bf 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 @@ -29,14 +29,15 @@ class File(BaseModel): source_uri: Optional[StrictStr] = Field(default=None, description="Test capitalization", alias="sourceURI") __properties = ["sourceURI"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> File: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> File: return None if not isinstance(obj, dict): - return File.parse_obj(obj) + return File.model_validate(obj) - _obj = File.parse_obj({ + _obj = File.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 ea8a6dbc550f..cacb59dc918c 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 @@ -30,14 +30,15 @@ class FileSchemaTestClass(BaseModel): files: Optional[List[File]] = None __properties = ["file", "files"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> FileSchemaTestClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -74,9 +75,9 @@ def from_dict(cls, obj: dict) -> FileSchemaTestClass: return None if not isinstance(obj, dict): - return FileSchemaTestClass.parse_obj(obj) + return FileSchemaTestClass.model_validate(obj) - _obj = FileSchemaTestClass.parse_obj({ + _obj = FileSchemaTestClass.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 4807f0acec7a..78dcfa435b3c 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 @@ -29,14 +29,15 @@ class FirstRef(BaseModel): self_ref: Optional[SecondRef] = None __properties = ["category", "self_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> FirstRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> FirstRef: return None if not isinstance(obj, dict): - return FirstRef.parse_obj(obj) + return FirstRef.model_validate(obj) - _obj = FirstRef.parse_obj({ + _obj = FirstRef.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 61d26e02f536..b26e388a28aa 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 @@ -28,14 +28,15 @@ class Foo(BaseModel): bar: Optional[StrictStr] = 'bar' __properties = ["bar"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -49,7 +50,7 @@ def from_json(cls, json_str: str) -> Foo: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -62,9 +63,9 @@ def from_dict(cls, obj: dict) -> Foo: return None if not isinstance(obj, dict): - return Foo.parse_obj(obj) + return Foo.model_validate(obj) - _obj = Foo.parse_obj({ + _obj = Foo.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 2b4697c9e9af..8aa1c763e88b 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 @@ -29,14 +29,15 @@ class FooGetDefaultResponse(BaseModel): string: Optional[Foo] = None __properties = ["string"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> FooGetDefaultResponse: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> FooGetDefaultResponse: return None if not isinstance(obj, dict): - return FooGetDefaultResponse.parse_obj(obj) + return FooGetDefaultResponse.model_validate(obj) - _obj = FooGetDefaultResponse.parse_obj({ + _obj = FooGetDefaultResponse.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 f2efd815cdf7..69980df9fab5 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 @@ -19,7 +19,7 @@ from datetime import date, datetime from typing import Optional, Union -from pydantic import BaseModel, StrictBytes, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictBytes, StrictInt, StrictStr, field_validator from decimal import Decimal from pydantic import Field from typing_extensions import Annotated @@ -46,7 +46,7 @@ class FormatTest(BaseModel): pattern_with_digits_and_delimiter: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.") __properties = ["integer", "int32", "int64", "number", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"] - @validator('string') + @field_validator('string') def string_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -56,7 +56,7 @@ def string_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /[a-z]/i") return value - @validator('string_with_double_quote_pattern') + @field_validator('string_with_double_quote_pattern') def string_with_double_quote_pattern_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -66,7 +66,7 @@ def string_with_double_quote_pattern_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /this is \"something\"/") return value - @validator('pattern_with_digits') + @field_validator('pattern_with_digits') def pattern_with_digits_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -76,7 +76,7 @@ def pattern_with_digits_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^\d{10}$/") return value - @validator('pattern_with_digits_and_delimiter') + @field_validator('pattern_with_digits_and_delimiter') def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -86,14 +86,15 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^image_\d{1,3}$/i") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -107,7 +108,7 @@ def from_json(cls, json_str: str) -> FormatTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -120,9 +121,9 @@ def from_dict(cls, obj: dict) -> FormatTest: return None if not isinstance(obj, dict): - return FormatTest.parse_obj(obj) + return FormatTest.model_validate(obj) - _obj = FormatTest.parse_obj({ + _obj = FormatTest.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 bde5806252fe..bdb291e1f6af 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 @@ -29,14 +29,15 @@ class HasOnlyReadOnly(BaseModel): foo: Optional[StrictStr] = None __properties = ["bar", "foo"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> HasOnlyReadOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "bar", "foo", @@ -65,9 +66,9 @@ def from_dict(cls, obj: dict) -> HasOnlyReadOnly: return None if not isinstance(obj, dict): - return HasOnlyReadOnly.parse_obj(obj) + return HasOnlyReadOnly.model_validate(obj) - _obj = HasOnlyReadOnly.parse_obj({ + _obj = HasOnlyReadOnly.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 e8e0efdc8ee2..7328147fd7ab 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 @@ -29,14 +29,15 @@ class HealthCheckResult(BaseModel): nullable_message: Optional[StrictStr] = Field(default=None, alias="NullableMessage") __properties = ["NullableMessage"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,13 +51,13 @@ def from_json(cls, json_str: str) -> HealthCheckResult: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) # set to None if nullable_message (nullable) is None - # and __fields_set__ contains the field - if self.nullable_message is None and "nullable_message" in self.__fields_set__: + # and model_fields_set contains the field + if self.nullable_message is None and "nullable_message" in self.model_fields_set: _dict['NullableMessage'] = None return _dict @@ -68,9 +69,9 @@ def from_dict(cls, obj: dict) -> HealthCheckResult: return None if not isinstance(obj, dict): - return HealthCheckResult.parse_obj(obj) + return HealthCheckResult.model_validate(obj) - _obj = HealthCheckResult.parse_obj({ + _obj = HealthCheckResult.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 97ee832e0516..fabd6b43f09a 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 @@ -29,14 +29,15 @@ class InnerDictWithProperty(BaseModel): a_property: Optional[Union[str, Any]] = Field(default=None, alias="aProperty") __properties = ["aProperty"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> InnerDictWithProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> InnerDictWithProperty: return None if not isinstance(obj, dict): - return InnerDictWithProperty.parse_obj(obj) + return InnerDictWithProperty.model_validate(obj) - _obj = InnerDictWithProperty.parse_obj({ + _obj = InnerDictWithProperty.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 a292b747c56c..0fb43ecaebb3 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class IntOrString(BaseModel): # data type: str oneof_schema_2_validator: Optional[StrictStr] = None actual_instance: Optional[Union[int, str]] = None - one_of_schemas: List[str] = Literal[INTORSTRING_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["int", "str"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -52,9 +54,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.construct() + instance = IntOrString.model_construct() error_messages = [] match = 0 # validate data type: int @@ -85,7 +87,7 @@ def from_dict(cls, obj: dict) -> IntOrString: @classmethod def from_json(cls, json_str: str) -> IntOrString: """Returns the object represented by the json string""" - instance = IntOrString.construct() + instance = IntOrString.model_construct() error_messages = [] match = 0 @@ -142,6 +144,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 d6f8d8f88359..be0719de484a 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 @@ -29,14 +29,15 @@ class List(BaseModel): var_123_list: Optional[StrictStr] = Field(default=None, alias="123-list") __properties = ["123-list"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> List: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> List: return None if not isinstance(obj, dict): - return List.parse_obj(obj) + return List.model_validate(obj) - _obj = List.parse_obj({ + _obj = List.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 2f31f5170b96..df4f9d9c4d7c 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 @@ -30,14 +30,15 @@ class MapOfArrayOfModel(BaseModel): shop_id_to_org_online_lip_map: Optional[Dict[str, List[Tag]]] = Field(default=None, alias="shopIdToOrgOnlineLipMap") __properties = ["shopIdToOrgOnlineLipMap"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> MapOfArrayOfModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> MapOfArrayOfModel: return None if not isinstance(obj, dict): - return MapOfArrayOfModel.parse_obj(obj) + return MapOfArrayOfModel.model_validate(obj) - _obj = MapOfArrayOfModel.parse_obj({ + _obj = MapOfArrayOfModel.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 7e5de1928beb..4745dbbfe80b 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 @@ -19,7 +19,7 @@ from typing import Dict, Optional -from pydantic import BaseModel, StrictBool, StrictStr, validator +from pydantic import BaseModel, StrictBool, StrictStr, field_validator class MapTest(BaseModel): """ @@ -31,7 +31,7 @@ class MapTest(BaseModel): indirect_map: Optional[Dict[str, StrictBool]] = None __properties = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] - @validator('map_of_enum_string') + @field_validator('map_of_enum_string') def map_of_enum_string_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -41,14 +41,15 @@ def map_of_enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -62,7 +63,7 @@ def from_json(cls, json_str: str) -> MapTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -75,9 +76,9 @@ def from_dict(cls, obj: dict) -> MapTest: return None if not isinstance(obj, dict): - return MapTest.parse_obj(obj) + return MapTest.model_validate(obj) - _obj = MapTest.parse_obj({ + _obj = MapTest.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 9e6ac0ee2497..0a6374269555 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 @@ -32,14 +32,15 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): map: Optional[Dict[str, Animal]] = None __properties = ["uuid", "dateTime", "map"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> MixedPropertiesAndAdditionalPropertiesClass def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> MixedPropertiesAndAdditionalPropertiesClass: return None if not isinstance(obj, dict): - return MixedPropertiesAndAdditionalPropertiesClass.parse_obj(obj) + return MixedPropertiesAndAdditionalPropertiesClass.model_validate(obj) - _obj = MixedPropertiesAndAdditionalPropertiesClass.parse_obj({ + _obj = MixedPropertiesAndAdditionalPropertiesClass.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 ded7bc23eef5..fc1d271ca45e 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 @@ -30,14 +30,15 @@ class Model200Response(BaseModel): var_class: Optional[StrictStr] = Field(default=None, alias="class") __properties = ["name", "class"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Model200Response: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> Model200Response: return None if not isinstance(obj, dict): - return Model200Response.parse_obj(obj) + return Model200Response.model_validate(obj) - _obj = Model200Response.parse_obj({ + _obj = Model200Response.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 47640cb68222..33c2edf0d81a 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 @@ -29,14 +29,15 @@ class ModelReturn(BaseModel): var_return: Optional[StrictInt] = Field(default=None, alias="return") __properties = ["return"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ModelReturn: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> ModelReturn: return None if not isinstance(obj, dict): - return ModelReturn.parse_obj(obj) + return ModelReturn.model_validate(obj) - _obj = ModelReturn.parse_obj({ + _obj = ModelReturn.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 863af2756db3..31caeb082027 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 @@ -32,14 +32,15 @@ class Name(BaseModel): var_123_number: Optional[StrictInt] = Field(default=None, alias="123Number") __properties = ["name", "snake_case", "property", "123Number"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> Name: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "snake_case", "var_123_number", @@ -68,9 +69,9 @@ def from_dict(cls, obj: dict) -> Name: return None if not isinstance(obj, dict): - return Name.parse_obj(obj) + return Name.model_validate(obj) - _obj = Name.parse_obj({ + _obj = Name.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 f4317671731d..df5f2998f01d 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 @@ -41,14 +41,15 @@ class NullableClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -62,7 +63,7 @@ def from_json(cls, json_str: str) -> NullableClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,58 +74,58 @@ def to_dict(self): _dict[_key] = _value # set to None if required_integer_prop (nullable) is None - # and __fields_set__ contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: _dict['required_integer_prop'] = None # set to None if integer_prop (nullable) is None - # and __fields_set__ contains the field - if self.integer_prop is None and "integer_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.integer_prop is None and "integer_prop" in self.model_fields_set: _dict['integer_prop'] = None # set to None if number_prop (nullable) is None - # and __fields_set__ contains the field - if self.number_prop is None and "number_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.number_prop is None and "number_prop" in self.model_fields_set: _dict['number_prop'] = None # set to None if boolean_prop (nullable) is None - # and __fields_set__ contains the field - if self.boolean_prop is None and "boolean_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: _dict['boolean_prop'] = None # set to None if string_prop (nullable) is None - # and __fields_set__ contains the field - if self.string_prop is None and "string_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.string_prop is None and "string_prop" in self.model_fields_set: _dict['string_prop'] = None # set to None if date_prop (nullable) is None - # and __fields_set__ contains the field - if self.date_prop is None and "date_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.date_prop is None and "date_prop" in self.model_fields_set: _dict['date_prop'] = None # set to None if datetime_prop (nullable) is None - # and __fields_set__ contains the field - if self.datetime_prop is None and "datetime_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: _dict['datetime_prop'] = None # set to None if array_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: _dict['array_nullable_prop'] = None # set to None if array_and_items_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: _dict['array_and_items_nullable_prop'] = None # set to None if object_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: _dict['object_nullable_prop'] = None # set to None if object_and_items_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: _dict['object_and_items_nullable_prop'] = None return _dict @@ -136,9 +137,9 @@ def from_dict(cls, obj: dict) -> NullableClass: return None if not isinstance(obj, dict): - return NullableClass.parse_obj(obj) + return NullableClass.model_validate(obj) - _obj = NullableClass.parse_obj({ + _obj = NullableClass.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 5ef7bed3503c..08b1946c58ff 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 @@ -19,7 +19,7 @@ from typing import Optional -from pydantic import BaseModel, StrictInt, validator +from pydantic import BaseModel, StrictInt, field_validator from pydantic import Field from typing_extensions import Annotated @@ -31,7 +31,7 @@ class NullableProperty(BaseModel): name: Optional[Annotated[str, Field(strict=True)]] __properties = ["id", "name"] - @validator('name') + @field_validator('name') def name_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -41,14 +41,15 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Z].*/") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -62,13 +63,13 @@ def from_json(cls, json_str: str) -> NullableProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) # set to None if name (nullable) is None - # and __fields_set__ contains the field - if self.name is None and "name" in self.__fields_set__: + # and model_fields_set contains the field + if self.name is None and "name" in self.model_fields_set: _dict['name'] = None return _dict @@ -80,9 +81,9 @@ def from_dict(cls, obj: dict) -> NullableProperty: return None if not isinstance(obj, dict): - return NullableProperty.parse_obj(obj) + return NullableProperty.model_validate(obj) - _obj = NullableProperty.parse_obj({ + _obj = NullableProperty.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 fb5087505866..384ba5f7aa52 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 @@ -29,14 +29,15 @@ class NumberOnly(BaseModel): just_number: Optional[float] = Field(default=None, alias="JustNumber") __properties = ["JustNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> NumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> NumberOnly: return None if not isinstance(obj, dict): - return NumberOnly.parse_obj(obj) + return NumberOnly.model_validate(obj) - _obj = NumberOnly.parse_obj({ + _obj = NumberOnly.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 582a0193ab9d..be3a1b2ce566 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 @@ -29,14 +29,15 @@ class ObjectToTestAdditionalProperties(BaseModel): var_property: Optional[StrictBool] = Field(default=False, description="Property", alias="property") __properties = ["property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ObjectToTestAdditionalProperties: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> ObjectToTestAdditionalProperties: return None if not isinstance(obj, dict): - return ObjectToTestAdditionalProperties.parse_obj(obj) + return ObjectToTestAdditionalProperties.model_validate(obj) - _obj = ObjectToTestAdditionalProperties.parse_obj({ + _obj = ObjectToTestAdditionalProperties.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 7e2f6c5169ed..805d4ce5396b 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 @@ -33,14 +33,15 @@ class ObjectWithDeprecatedFields(BaseModel): bars: Optional[List[StrictStr]] = None __properties = ["uuid", "id", "deprecatedRef", "bars"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> ObjectWithDeprecatedFields: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ObjectWithDeprecatedFields: return None if not isinstance(obj, dict): - return ObjectWithDeprecatedFields.parse_obj(obj) + return ObjectWithDeprecatedFields.model_validate(obj) - _obj = ObjectWithDeprecatedFields.parse_obj({ + _obj = ObjectWithDeprecatedFields.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 dfc27aa88200..65067fe7620e 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class OneOfEnumString(BaseModel): # data type: EnumString2 oneof_schema_2_validator: Optional[EnumString2] = None actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: List[str] = Literal[ONEOFENUMSTRING_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -52,9 +54,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = OneOfEnumString.construct() + instance = OneOfEnumString.model_construct() error_messages = [] match = 0 # validate data type: EnumString1 @@ -83,7 +85,7 @@ def from_dict(cls, obj: dict) -> OneOfEnumString: @classmethod def from_json(cls, json_str: str) -> OneOfEnumString: """Returns the object represented by the json string""" - instance = OneOfEnumString.construct() + instance = OneOfEnumString.model_construct() error_messages = [] match = 0 @@ -134,6 +136,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 aae37c06e58a..d44585a9dde8 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 @@ -19,7 +19,7 @@ from datetime import datetime from typing import Optional -from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, field_validator from pydantic import Field class Order(BaseModel): @@ -34,7 +34,7 @@ class Order(BaseModel): complete: Optional[StrictBool] = False __properties = ["id", "petId", "quantity", "shipDate", "status", "complete"] - @validator('status') + @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -44,14 +44,15 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -65,7 +66,7 @@ def from_json(cls, json_str: str) -> Order: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -78,9 +79,9 @@ def from_dict(cls, obj: dict) -> Order: return None if not isinstance(obj, dict): - return Order.parse_obj(obj) + return Order.model_validate(obj) - _obj = Order.parse_obj({ + _obj = Order.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 75d106c4dbfe..1f6f60549eac 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 @@ -30,14 +30,15 @@ class OuterComposite(BaseModel): my_boolean: Optional[StrictBool] = None __properties = ["my_number", "my_string", "my_boolean"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> OuterComposite: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> OuterComposite: return None if not isinstance(obj, dict): - return OuterComposite.parse_obj(obj) + return OuterComposite.model_validate(obj) - _obj = OuterComposite.parse_obj({ + _obj = OuterComposite.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_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 4baa10251adc..6ac81887102e 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 @@ -31,14 +31,15 @@ class OuterObjectWithEnumProperty(BaseModel): value: OuterEnumInteger __properties = ["str_value", "value"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,13 +53,13 @@ def from_json(cls, json_str: str) -> OuterObjectWithEnumProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) # set to None if str_value (nullable) is None - # and __fields_set__ contains the field - if self.str_value is None and "str_value" in self.__fields_set__: + # and model_fields_set contains the field + if self.str_value is None and "str_value" in self.model_fields_set: _dict['str_value'] = None return _dict @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> OuterObjectWithEnumProperty: return None if not isinstance(obj, dict): - return OuterObjectWithEnumProperty.parse_obj(obj) + return OuterObjectWithEnumProperty.model_validate(obj) - _obj = OuterObjectWithEnumProperty.parse_obj({ + _obj = OuterObjectWithEnumProperty.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 b90b8cda3cb9..d31cc7b86f39 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 @@ -30,14 +30,15 @@ class Parent(BaseModel): optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict") __properties = ["optionalDict"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Parent: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> Parent: return None if not isinstance(obj, dict): - return Parent.parse_obj(obj) + return Parent.model_validate(obj) - _obj = Parent.parse_obj({ + _obj = Parent.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 9d606221821c..c834b3d5f741 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 @@ -30,14 +30,15 @@ class ParentWithOptionalDict(BaseModel): optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict") __properties = ["optionalDict"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ParentWithOptionalDict: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> ParentWithOptionalDict: return None if not isinstance(obj, dict): - return ParentWithOptionalDict.parse_obj(obj) + return ParentWithOptionalDict.model_validate(obj) - _obj = ParentWithOptionalDict.parse_obj({ + _obj = ParentWithOptionalDict.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 8aff3b94e81f..c76cc47797c5 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 @@ -19,7 +19,7 @@ from typing import List, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from typing_extensions import Annotated from petstore_api.models.category import Category @@ -32,12 +32,12 @@ class Pet(BaseModel): id: Optional[StrictInt] = None category: Optional[Category] = None name: StrictStr - photo_urls: Annotated[List[StrictStr], Field(min_items=0)] = Field(alias="photoUrls") + photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None status: Optional[StrictStr] = Field(default=None, description="pet status in the store") __properties = ["id", "category", "name", "photoUrls", "tags", "status"] - @validator('status') + @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -47,14 +47,15 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -68,7 +69,7 @@ def from_json(cls, json_str: str) -> Pet: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -91,9 +92,9 @@ def from_dict(cls, obj: dict) -> Pet: return None if not isinstance(obj, dict): - return Pet.parse_obj(obj) + return Pet.model_validate(obj) - _obj = Pet.parse_obj({ + _obj = Pet.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 3c72f9816b81..7af8f7ee8e3c 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class Pig(BaseModel): # data type: DanishPig oneof_schema_2_validator: Optional[DanishPig] = None actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: List[str] = Literal[PIG_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True discriminator_value_class_map: Dict[str, str] = { } @@ -55,9 +57,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = Pig.construct() + instance = Pig.model_construct() error_messages = [] match = 0 # validate data type: BasquePig @@ -86,7 +88,7 @@ def from_dict(cls, obj: dict) -> Pig: @classmethod def from_json(cls, json_str: str) -> Pig: """Returns the object represented by the json string""" - instance = Pig.construct() + instance = Pig.model_construct() error_messages = [] match = 0 @@ -137,6 +139,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 063376fa5378..af6d6cc1906e 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 @@ -31,14 +31,15 @@ class PropertyNameCollision(BaseModel): type_: Optional[StrictStr] = None __properties = ["_type", "type", "type_"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> PropertyNameCollision: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -65,9 +66,9 @@ def from_dict(cls, obj: dict) -> PropertyNameCollision: return None if not isinstance(obj, dict): - return PropertyNameCollision.parse_obj(obj) + return PropertyNameCollision.model_validate(obj) - _obj = PropertyNameCollision.parse_obj({ + _obj = PropertyNameCollision.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 6c63efe2145e..8a34b0acc32d 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 @@ -29,14 +29,15 @@ class ReadOnlyFirst(BaseModel): baz: Optional[StrictStr] = None __properties = ["bar", "baz"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> ReadOnlyFirst: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "bar", }, @@ -64,9 +65,9 @@ def from_dict(cls, obj: dict) -> ReadOnlyFirst: return None if not isinstance(obj, dict): - return ReadOnlyFirst.parse_obj(obj) + return ReadOnlyFirst.model_validate(obj) - _obj = ReadOnlyFirst.parse_obj({ + _obj = ReadOnlyFirst.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 f4fb35ab2313..5202c14fed90 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 @@ -29,14 +29,15 @@ class SecondRef(BaseModel): circular_ref: Optional[CircularReferenceModel] = None __properties = ["category", "circular_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> SecondRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> SecondRef: return None if not isinstance(obj, dict): - return SecondRef.parse_obj(obj) + return SecondRef.model_validate(obj) - _obj = SecondRef.parse_obj({ + _obj = SecondRef.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 bf9d13067ce3..b6b521e40966 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 @@ -29,14 +29,15 @@ class SelfReferenceModel(BaseModel): nested: Optional[DummyModel] = None __properties = ["size", "nested"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> SelfReferenceModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -66,9 +67,9 @@ def from_dict(cls, obj: dict) -> SelfReferenceModel: return None if not isinstance(obj, dict): - return SelfReferenceModel.parse_obj(obj) + return SelfReferenceModel.model_validate(obj) - _obj = SelfReferenceModel.parse_obj({ + _obj = SelfReferenceModel.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/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 20040798b508..e9c82e37092d 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 @@ -29,14 +29,15 @@ class SpecialModelName(BaseModel): special_property_name: Optional[StrictInt] = Field(default=None, alias="$special[property.name]") __properties = ["$special[property.name]"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> SpecialModelName: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> SpecialModelName: return None if not isinstance(obj, dict): - return SpecialModelName.parse_obj(obj) + return SpecialModelName.model_validate(obj) - _obj = SpecialModelName.parse_obj({ + _obj = SpecialModelName.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 b5c7281a347b..8cbf678f3c34 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 @@ -19,7 +19,7 @@ from typing import Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.category import Category @@ -32,7 +32,7 @@ class SpecialName(BaseModel): var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") __properties = ["property", "async", "schema"] - @validator('var_schema') + @field_validator('var_schema') def var_schema_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -42,14 +42,15 @@ def var_schema_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -63,7 +64,7 @@ def from_json(cls, json_str: str) -> SpecialName: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -79,9 +80,9 @@ def from_dict(cls, obj: dict) -> SpecialName: return None if not isinstance(obj, dict): - return SpecialName.parse_obj(obj) + return SpecialName.model_validate(obj) - _obj = SpecialName.parse_obj({ + _obj = SpecialName.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 4a9fbc678523..8a7251eefbe1 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 @@ -29,14 +29,15 @@ class Tag(BaseModel): name: Optional[StrictStr] = None __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Tag: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -63,9 +64,9 @@ def from_dict(cls, obj: dict) -> Tag: return None if not isinstance(obj, dict): - return Tag.parse_obj(obj) + return Tag.model_validate(obj) - _obj = Tag.parse_obj({ + _obj = Tag.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 4b811a07bf9d..ffda6891843c 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 @@ -30,14 +30,15 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["someProperty"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> TestInlineFreeformAdditionalPropertiesReque def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> TestInlineFreeformAdditionalPropertiesRequest: return None if not isinstance(obj, dict): - return TestInlineFreeformAdditionalPropertiesRequest.parse_obj(obj) + return TestInlineFreeformAdditionalPropertiesRequest.model_validate(obj) - _obj = TestInlineFreeformAdditionalPropertiesRequest.parse_obj({ + _obj = TestInlineFreeformAdditionalPropertiesRequest.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 7a8ec99bc8fb..d0678ac15d1f 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 @@ -28,14 +28,15 @@ class Tiger(BaseModel): skill: Optional[StrictStr] = None __properties = ["skill"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -49,7 +50,7 @@ def from_json(cls, json_str: str) -> Tiger: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -62,9 +63,9 @@ def from_dict(cls, obj: dict) -> Tiger: return None if not isinstance(obj, dict): - return Tiger.parse_obj(obj) + return Tiger.model_validate(obj) - _obj = Tiger.parse_obj({ + _obj = Tiger.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 937221ec7a6f..b2c1e3c7e3fd 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 @@ -36,14 +36,15 @@ class User(BaseModel): user_status: Optional[StrictInt] = Field(default=None, description="User Status", alias="userStatus") __properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -57,7 +58,7 @@ def from_json(cls, json_str: str) -> User: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> User: return None if not isinstance(obj, dict): - return User.parse_obj(obj) + return User.model_validate(obj) - _obj = User.parse_obj({ + _obj = User.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 a5f52af9e146..0d8f7616827f 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 @@ -32,14 +32,15 @@ class WithNestedOneOf(BaseModel): nested_oneof_enum_string: Optional[OneOfEnumString] = None __properties = ["size", "nested_pig", "nested_oneof_enum_string"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> WithNestedOneOf: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ }, exclude_none=True) @@ -72,9 +73,9 @@ def from_dict(cls, obj: dict) -> WithNestedOneOf: return None if not isinstance(obj, dict): - return WithNestedOneOf.parse_obj(obj) + return WithNestedOneOf.model_validate(obj) - _obj = WithNestedOneOf.parse_obj({ + _obj = WithNestedOneOf.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/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index 9eabf5fb45bf..f1e942608b7f 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -42,7 +42,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def call_123_test_special_tags(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test special tags # noqa: E501 @@ -72,7 +72,7 @@ def call_123_test_special_tags(self, client : Annotated[Client, Field(descriptio raise ValueError(message) return self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def call_123_test_special_tags_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test special tags # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index b52692877379..79a8f572630f 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from petstore_api.models.foo_get_default_response import FooGetDefaultResponse @@ -40,7 +40,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def foo_get(self, **kwargs) -> FooGetDefaultResponse: # noqa: E501 """foo_get # noqa: E501 @@ -67,7 +67,7 @@ def foo_get(self, **kwargs) -> FooGetDefaultResponse: # noqa: E501 raise ValueError(message) return self.foo_get_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def foo_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """foo_get # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 58460fe91128..59b139c1e67e 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -16,13 +16,13 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated from datetime import date, datetime -from pydantic import StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, validator +from pydantic import StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, field_validator from typing import Any, Dict, List, Optional, Union @@ -57,7 +57,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def fake_any_type_request_body(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> None: # noqa: E501 """test any type request body # noqa: E501 @@ -86,7 +86,7 @@ def fake_any_type_request_body(self, body : Optional[Dict[str, Any]] = None, **k raise ValueError(message) return self.fake_any_type_request_body_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_any_type_request_body_with_http_info(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse: # noqa: E501 """test any type request body # noqa: E501 @@ -196,7 +196,7 @@ def fake_any_type_request_body_with_http_info(self, body : Optional[Dict[str, An collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_enum_ref_query_parameter(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> None: # noqa: E501 """test enum reference query parameter # noqa: E501 @@ -225,7 +225,7 @@ def fake_enum_ref_query_parameter(self, enum_ref : Annotated[Optional[EnumClass] raise ValueError(message) return self.fake_enum_ref_query_parameter_with_http_info(enum_ref, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_enum_ref_query_parameter_with_http_info(self, enum_ref : Annotated[Optional[EnumClass], Field(description="enum reference")] = None, **kwargs) -> ApiResponse: # noqa: E501 """test enum reference query parameter # noqa: E501 @@ -328,7 +328,7 @@ def fake_enum_ref_query_parameter_with_http_info(self, enum_ref : Annotated[Opti collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_health_get(self, **kwargs) -> HealthCheckResult: # noqa: E501 """Health check endpoint # noqa: E501 @@ -355,7 +355,7 @@ def fake_health_get(self, **kwargs) -> HealthCheckResult: # noqa: E501 raise ValueError(message) return self.fake_health_get_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Health check endpoint # noqa: E501 @@ -458,7 +458,7 @@ def fake_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_http_signature_test(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> None: # noqa: E501 """test http signature authentication # noqa: E501 @@ -491,7 +491,7 @@ def fake_http_signature_test(self, pet : Annotated[Pet, Field(description="Pet o raise ValueError(message) return self.fake_http_signature_test_with_http_info(pet, query_1, header_1, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_http_signature_test_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], query_1 : Annotated[Optional[StrictStr], Field(description="query parameter")] = None, header_1 : Annotated[Optional[StrictStr], Field(description="header parameter")] = None, **kwargs) -> ApiResponse: # noqa: E501 """test http signature authentication # noqa: E501 @@ -613,7 +613,7 @@ def fake_http_signature_test_with_http_info(self, pet : Annotated[Pet, Field(des collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_outer_boolean_serialize(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> bool: # noqa: E501 """fake_outer_boolean_serialize # noqa: E501 @@ -643,7 +643,7 @@ def fake_outer_boolean_serialize(self, body : Annotated[Optional[StrictBool], Fi raise ValueError(message) return self.fake_outer_boolean_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_outer_boolean_serialize_with_http_info(self, body : Annotated[Optional[StrictBool], Field(description="Input boolean as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_boolean_serialize # noqa: E501 @@ -760,7 +760,7 @@ def fake_outer_boolean_serialize_with_http_info(self, body : Annotated[Optional[ collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_outer_composite_serialize(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> OuterComposite: # noqa: E501 """fake_outer_composite_serialize # noqa: E501 @@ -790,7 +790,7 @@ def fake_outer_composite_serialize(self, outer_composite : Annotated[Optional[Ou raise ValueError(message) return self.fake_outer_composite_serialize_with_http_info(outer_composite, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_outer_composite_serialize_with_http_info(self, outer_composite : Annotated[Optional[OuterComposite], Field(description="Input composite as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_composite_serialize # noqa: E501 @@ -907,7 +907,7 @@ def fake_outer_composite_serialize_with_http_info(self, outer_composite : Annota collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_outer_number_serialize(self, body : Annotated[Optional[StrictFloat], Field(description="Input number as post body")] = None, **kwargs) -> float: # noqa: E501 """fake_outer_number_serialize # noqa: E501 @@ -937,7 +937,7 @@ def fake_outer_number_serialize(self, body : Annotated[Optional[StrictFloat], Fi raise ValueError(message) return self.fake_outer_number_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_outer_number_serialize_with_http_info(self, body : Annotated[Optional[StrictFloat], Field(description="Input number as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_number_serialize # noqa: E501 @@ -1054,7 +1054,7 @@ def fake_outer_number_serialize_with_http_info(self, body : Annotated[Optional[S collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_outer_string_serialize(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> str: # noqa: E501 """fake_outer_string_serialize # noqa: E501 @@ -1084,7 +1084,7 @@ def fake_outer_string_serialize(self, body : Annotated[Optional[StrictStr], Fiel raise ValueError(message) return self.fake_outer_string_serialize_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_outer_string_serialize_with_http_info(self, body : Annotated[Optional[StrictStr], Field(description="Input string as post body")] = None, **kwargs) -> ApiResponse: # noqa: E501 """fake_outer_string_serialize # noqa: E501 @@ -1201,7 +1201,7 @@ def fake_outer_string_serialize_with_http_info(self, body : Annotated[Optional[S collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_property_enum_integer_serialize(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(description="Input enum (int) as post body")], **kwargs) -> OuterObjectWithEnumProperty: # noqa: E501 """fake_property_enum_integer_serialize # noqa: E501 @@ -1231,7 +1231,7 @@ def fake_property_enum_integer_serialize(self, outer_object_with_enum_property : raise ValueError(message) return self.fake_property_enum_integer_serialize_with_http_info(outer_object_with_enum_property, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_enum_property : Annotated[OuterObjectWithEnumProperty, Field(description="Input enum (int) as post body")], **kwargs) -> ApiResponse: # noqa: E501 """fake_property_enum_integer_serialize # noqa: E501 @@ -1348,7 +1348,7 @@ def fake_property_enum_integer_serialize_with_http_info(self, outer_object_with_ collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_return_list_of_objects(self, **kwargs) -> List[List[Tag]]: # noqa: E501 """test returning list of objects # noqa: E501 @@ -1375,7 +1375,7 @@ def fake_return_list_of_objects(self, **kwargs) -> List[List[Tag]]: # noqa: E50 raise ValueError(message) return self.fake_return_list_of_objects_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_return_list_of_objects_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """test returning list of objects # noqa: E501 @@ -1478,7 +1478,7 @@ def fake_return_list_of_objects_with_http_info(self, **kwargs) -> ApiResponse: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(description="uuid example")], **kwargs) -> None: # noqa: E501 """test uuid example # noqa: E501 @@ -1507,7 +1507,7 @@ def fake_uuid_example(self, uuid_example : Annotated[StrictStr, Field(descriptio raise ValueError(message) return self.fake_uuid_example_with_http_info(uuid_example, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def fake_uuid_example_with_http_info(self, uuid_example : Annotated[StrictStr, Field(description="uuid example")], **kwargs) -> ApiResponse: # noqa: E501 """test uuid example # noqa: E501 @@ -1610,7 +1610,7 @@ def fake_uuid_example_with_http_info(self, uuid_example : Annotated[StrictStr, F collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_body_with_binary(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="image to upload")], **kwargs) -> None: # noqa: E501 """test_body_with_binary # noqa: E501 @@ -1640,7 +1640,7 @@ def test_body_with_binary(self, body : Annotated[Optional[Union[StrictBytes, Str raise ValueError(message) return self.test_body_with_binary_with_http_info(body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_body_with_binary_with_http_info(self, body : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="image to upload")], **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_binary # noqa: E501 @@ -1756,7 +1756,7 @@ def test_body_with_binary_with_http_info(self, body : Annotated[Optional[Union[S collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_body_with_file_schema(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> None: # noqa: E501 """test_body_with_file_schema # noqa: E501 @@ -1786,7 +1786,7 @@ def test_body_with_file_schema(self, file_schema_test_class : FileSchemaTestClas raise ValueError(message) return self.test_body_with_file_schema_with_http_info(file_schema_test_class, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_body_with_file_schema_with_http_info(self, file_schema_test_class : FileSchemaTestClass, **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_file_schema # noqa: E501 @@ -1897,7 +1897,7 @@ def test_body_with_file_schema_with_http_info(self, file_schema_test_class : Fil collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_body_with_query_params(self, query : StrictStr, user : User, **kwargs) -> None: # noqa: E501 """test_body_with_query_params # noqa: E501 @@ -1928,7 +1928,7 @@ def test_body_with_query_params(self, query : StrictStr, user : User, **kwargs) raise ValueError(message) return self.test_body_with_query_params_with_http_info(query, user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_body_with_query_params_with_http_info(self, query : StrictStr, user : User, **kwargs) -> ApiResponse: # noqa: E501 """test_body_with_query_params # noqa: E501 @@ -2044,7 +2044,7 @@ def test_body_with_query_params_with_http_info(self, query : StrictStr, user : U collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_client_model(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test \"client\" model # noqa: E501 @@ -2074,7 +2074,7 @@ def test_client_model(self, client : Annotated[Client, Field(description="client raise ValueError(message) return self.test_client_model_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_client_model_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test \"client\" model # noqa: E501 @@ -2191,7 +2191,7 @@ def test_client_model_with_http_info(self, client : Annotated[Client, Field(desc collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_date_time_query_parameter(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> None: # noqa: E501 """test_date_time_query_parameter # noqa: E501 @@ -2222,7 +2222,7 @@ def test_date_time_query_parameter(self, date_time_query : datetime, str_query : raise ValueError(message) return self.test_date_time_query_parameter_with_http_info(date_time_query, str_query, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_date_time_query_parameter_with_http_info(self, date_time_query : datetime, str_query : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 """test_date_time_query_parameter # noqa: E501 @@ -2334,7 +2334,7 @@ def test_date_time_query_parameter_with_http_info(self, date_time_query : dateti collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_endpoint_parameters(self, number : Annotated[float, Field(le=543.2, strict=True, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, strict=True, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6, strict=True)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(strict=True, max_length=64)]]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2392,7 +2392,7 @@ def test_endpoint_parameters(self, number : Annotated[float, Field(le=543.2, str raise ValueError(message) return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, byte_with_max_length, var_date, date_time, password, param_callback, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_endpoint_parameters_with_http_info(self, number : Annotated[float, Field(le=543.2, strict=True, ge=32.1, description="None")], double : Annotated[float, Field(le=123.4, strict=True, ge=67.8, description="None")], pattern_without_delimiter : Annotated[str, Field(strict=True, description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(description="None")], integer : Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=10)]], Field(description="None")] = None, int32 : Annotated[Optional[Annotated[int, Field(le=200, strict=True, ge=20)]], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[Annotated[float, Field(le=987.6, strict=True)]], Field(description="None")] = None, string : Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[Annotated[bytes, Field(strict=True, max_length=64)], Annotated[str, Field(strict=True, max_length=64)]]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[Annotated[str, Field(min_length=10, strict=True, max_length=64)]], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2587,7 +2587,7 @@ def test_endpoint_parameters_with_http_info(self, number : Annotated[float, Fiel collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_group_parameters(self, required_string_group : Annotated[StrictInt, Field(description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 @@ -2627,7 +2627,7 @@ def test_group_parameters(self, required_string_group : Annotated[StrictInt, Fie raise ValueError(message) return self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, string_group, boolean_group, int64_group, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_group_parameters_with_http_info(self, required_string_group : Annotated[StrictInt, Field(description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 @@ -2761,7 +2761,7 @@ def test_group_parameters_with_http_info(self, required_string_group : Annotated collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_inline_additional_properties(self, request_body : Annotated[Dict[str, StrictStr], Field(description="request body")], **kwargs) -> None: # noqa: E501 """test inline additionalProperties # noqa: E501 @@ -2791,7 +2791,7 @@ def test_inline_additional_properties(self, request_body : Annotated[Dict[str, S raise ValueError(message) return self.test_inline_additional_properties_with_http_info(request_body, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_inline_additional_properties_with_http_info(self, request_body : Annotated[Dict[str, StrictStr], Field(description="request body")], **kwargs) -> ApiResponse: # noqa: E501 """test inline additionalProperties # noqa: E501 @@ -2902,7 +2902,7 @@ def test_inline_additional_properties_with_http_info(self, request_body : Annota collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_inline_freeform_additional_properties(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> None: # noqa: E501 """test inline free-form additionalProperties # noqa: E501 @@ -2932,7 +2932,7 @@ def test_inline_freeform_additional_properties(self, test_inline_freeform_additi raise ValueError(message) return self.test_inline_freeform_additional_properties_with_http_info(test_inline_freeform_additional_properties_request, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_inline_freeform_additional_properties_with_http_info(self, test_inline_freeform_additional_properties_request : Annotated[TestInlineFreeformAdditionalPropertiesRequest, Field(description="request body")], **kwargs) -> ApiResponse: # noqa: E501 """test inline free-form additionalProperties # noqa: E501 @@ -3043,7 +3043,7 @@ def test_inline_freeform_additional_properties_with_http_info(self, test_inline_ collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_json_form_data(self, param : Annotated[StrictStr, Field(description="field1")], param2 : Annotated[StrictStr, Field(description="field2")], **kwargs) -> None: # noqa: E501 """test json serialization of form data # noqa: E501 @@ -3075,7 +3075,7 @@ def test_json_form_data(self, param : Annotated[StrictStr, Field(description="fi raise ValueError(message) return self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, Field(description="field1")], param2 : Annotated[StrictStr, Field(description="field2")], **kwargs) -> ApiResponse: # noqa: E501 """test json serialization of form data # noqa: E501 @@ -3192,7 +3192,7 @@ def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, Field( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def test_query_parameter_collection_format(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> None: # noqa: E501 """test_query_parameter_collection_format # noqa: E501 @@ -3234,7 +3234,7 @@ def test_query_parameter_collection_format(self, pipe : List[StrictStr], ioutil raise ValueError(message) return self.test_query_parameter_collection_format_with_http_info(pipe, ioutil, http, url, context, allow_empty, language, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_query_parameter_collection_format_with_http_info(self, pipe : List[StrictStr], ioutil : List[StrictStr], http : List[StrictStr], url : List[StrictStr], context : List[StrictStr], allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501 """test_query_parameter_collection_format # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index 342d93d861dd..89b898d96e00 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -42,7 +42,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def test_classname(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> Client: # noqa: E501 """To test class name in snake case # noqa: E501 @@ -72,7 +72,7 @@ def test_classname(self, client : Annotated[Client, Field(description="client mo raise ValueError(message) return self.test_classname_with_http_info(client, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def test_classname_with_http_info(self, client : Annotated[Client, Field(description="client model")], **kwargs) -> ApiResponse: # noqa: E501 """To test class name in snake case # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 90b585150c05..f95d2334d239 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -16,11 +16,11 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated -from pydantic import StrictBytes, StrictInt, StrictStr, validator +from pydantic import StrictBytes, StrictInt, StrictStr, field_validator from typing import List, Optional, Union @@ -47,7 +47,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def add_pet(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 """Add a new pet to the store # noqa: E501 @@ -77,7 +77,7 @@ def add_pet(self, pet : Annotated[Pet, Field(description="Pet object that needs raise ValueError(message) return self.add_pet_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def add_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 """Add a new pet to the store # noqa: E501 @@ -188,7 +188,7 @@ def add_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet obj collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def delete_pet(self, pet_id : Annotated[StrictInt, Field(description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 """Deletes a pet # noqa: E501 @@ -220,7 +220,7 @@ def delete_pet(self, pet_id : Annotated[StrictInt, Field(description="Pet id to raise ValueError(message) return self.delete_pet_with_http_info(pet_id, api_key, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def delete_pet_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="Pet id to delete")], api_key : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 """Deletes a pet # noqa: E501 @@ -330,7 +330,7 @@ def delete_pet_with_http_info(self, pet_id : Annotated[StrictInt, Field(descript collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def find_pets_by_status(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> List[Pet]: # noqa: E501 """Finds Pets by status # noqa: E501 @@ -360,7 +360,7 @@ def find_pets_by_status(self, status : Annotated[List[StrictStr], Field(descript raise ValueError(message) return self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def find_pets_by_status_with_http_info(self, status : Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], **kwargs) -> ApiResponse: # noqa: E501 """Finds Pets by status # noqa: E501 @@ -472,7 +472,7 @@ def find_pets_by_status_with_http_info(self, status : Annotated[List[StrictStr], collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def find_pets_by_tags(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> List[Pet]: # noqa: E501 """(Deprecated) Finds Pets by tags # noqa: E501 @@ -502,7 +502,7 @@ def find_pets_by_tags(self, tags : Annotated[List[StrictStr], Field(description= raise ValueError(message) return self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def find_pets_by_tags_with_http_info(self, tags : Annotated[List[StrictStr], Field(description="Tags to filter by")], **kwargs) -> ApiResponse: # noqa: E501 """(Deprecated) Finds Pets by tags # noqa: E501 @@ -616,7 +616,7 @@ def find_pets_by_tags_with_http_info(self, tags : Annotated[List[StrictStr], Fie collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to return")], **kwargs) -> Pet: # noqa: E501 """Find pet by ID # noqa: E501 @@ -646,7 +646,7 @@ def get_pet_by_id(self, pet_id : Annotated[StrictInt, Field(description="ID of p raise ValueError(message) return self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to return")], **kwargs) -> ApiResponse: # noqa: E501 """Find pet by ID # noqa: E501 @@ -758,7 +758,7 @@ def get_pet_by_id_with_http_info(self, pet_id : Annotated[StrictInt, Field(descr collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def update_pet(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> None: # noqa: E501 """Update an existing pet # noqa: E501 @@ -788,7 +788,7 @@ def update_pet(self, pet : Annotated[Pet, Field(description="Pet object that nee raise ValueError(message) return self.update_pet_with_http_info(pet, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def update_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet object that needs to be added to the store")], **kwargs) -> ApiResponse: # noqa: E501 """Update an existing pet # noqa: E501 @@ -899,7 +899,7 @@ def update_pet_with_http_info(self, pet : Annotated[Pet, Field(description="Pet collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def update_pet_with_form(self, pet_id : Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> None: # noqa: E501 """Updates a pet in the store with form data # noqa: E501 @@ -933,7 +933,7 @@ def update_pet_with_form(self, pet_id : Annotated[StrictInt, Field(description=" raise ValueError(message) return self.update_pet_with_form_with_http_info(pet_id, name, status, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def update_pet_with_form_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], name : Annotated[Optional[StrictStr], Field(description="Updated name of the pet")] = None, status : Annotated[Optional[StrictStr], Field(description="Updated status of the pet")] = None, **kwargs) -> ApiResponse: # noqa: E501 """Updates a pet in the store with form data # noqa: E501 @@ -1056,7 +1056,7 @@ def update_pet_with_form_with_http_info(self, pet_id : Annotated[StrictInt, Fiel collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def upload_file(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image # noqa: E501 @@ -1090,7 +1090,7 @@ def upload_file(self, pet_id : Annotated[StrictInt, Field(description="ID of pet raise ValueError(message) return self.upload_file_with_http_info(pet_id, additional_metadata, file, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def upload_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, file : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="file to upload")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image # noqa: E501 @@ -1219,7 +1219,7 @@ def upload_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(descrip collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def upload_file_with_required_file(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image (required) # noqa: E501 @@ -1253,7 +1253,7 @@ def upload_file_with_required_file(self, pet_id : Annotated[StrictInt, Field(des raise ValueError(message) return self.upload_file_with_required_file_with_http_info(pet_id, required_file, additional_metadata, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def upload_file_with_required_file_with_http_info(self, pet_id : Annotated[StrictInt, Field(description="ID of pet to update")], required_file : Annotated[Union[StrictBytes, StrictStr], Field(description="file to upload")], additional_metadata : Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")] = None, **kwargs) -> ApiResponse: # noqa: E501 """uploads an image (required) # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index 89334dee6d1f..e589c590403c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -46,7 +46,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def delete_order(self, order_id : Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")], **kwargs) -> None: # noqa: E501 """Delete purchase order by ID # noqa: E501 @@ -76,7 +76,7 @@ def delete_order(self, order_id : Annotated[StrictStr, Field(description="ID of raise ValueError(message) return self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def delete_order_with_http_info(self, order_id : Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 """Delete purchase order by ID # noqa: E501 @@ -180,7 +180,7 @@ def delete_order_with_http_info(self, order_id : Annotated[StrictStr, Field(desc collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def get_inventory(self, **kwargs) -> Dict[str, int]: # noqa: E501 """Returns pet inventories by status # noqa: E501 @@ -208,7 +208,7 @@ def get_inventory(self, **kwargs) -> Dict[str, int]: # noqa: E501 raise ValueError(message) return self.get_inventory_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def get_inventory_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Returns pet inventories by status # noqa: E501 @@ -312,7 +312,7 @@ def get_inventory_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def get_order_by_id(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> Order: # noqa: E501 """Find purchase order by ID # noqa: E501 @@ -342,7 +342,7 @@ def get_order_by_id(self, order_id : Annotated[int, Field(le=5, strict=True, ge= raise ValueError(message) return self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def get_order_by_id_with_http_info(self, order_id : Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], **kwargs) -> ApiResponse: # noqa: E501 """Find purchase order by ID # noqa: E501 @@ -454,7 +454,7 @@ def get_order_by_id_with_http_info(self, order_id : Annotated[int, Field(le=5, s collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def place_order(self, order : Annotated[Order, Field(description="order placed for purchasing the pet")], **kwargs) -> Order: # noqa: E501 """Place an order for a pet # noqa: E501 @@ -484,7 +484,7 @@ def place_order(self, order : Annotated[Order, Field(description="order placed f raise ValueError(message) return self.place_order_with_http_info(order, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def place_order_with_http_info(self, order : Annotated[Order, Field(description="order placed for purchasing the pet")], **kwargs) -> ApiResponse: # noqa: E501 """Place an order for a pet # noqa: E501 diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index ab1101af25cb..3420f8993a1a 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -16,7 +16,7 @@ import io import warnings -from pydantic import validate_arguments, ValidationError +from pydantic import validate_call, ValidationError from pydantic import Field from typing_extensions import Annotated @@ -46,7 +46,7 @@ def __init__(self, api_client=None) -> None: api_client = ApiClient.get_default() self.api_client = api_client - @validate_arguments + @validate_call def create_user(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> None: # noqa: E501 """Create user # noqa: E501 @@ -76,7 +76,7 @@ def create_user(self, user : Annotated[User, Field(description="Created user obj raise ValueError(message) return self.create_user_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def create_user_with_http_info(self, user : Annotated[User, Field(description="Created user object")], **kwargs) -> ApiResponse: # noqa: E501 """Create user # noqa: E501 @@ -202,7 +202,7 @@ def create_user_with_http_info(self, user : Annotated[User, Field(description="C collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def create_users_with_array_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -232,7 +232,7 @@ def create_users_with_array_input(self, user : Annotated[List[User], Field(descr raise ValueError(message) return self.create_users_with_array_input_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def create_users_with_array_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -343,7 +343,7 @@ def create_users_with_array_input_with_http_info(self, user : Annotated[List[Use collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def create_users_with_list_input(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> None: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -373,7 +373,7 @@ def create_users_with_list_input(self, user : Annotated[List[User], Field(descri raise ValueError(message) return self.create_users_with_list_input_with_http_info(user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def create_users_with_list_input_with_http_info(self, user : Annotated[List[User], Field(description="List of user object")], **kwargs) -> ApiResponse: # noqa: E501 """Creates list of users with given input array # noqa: E501 @@ -484,7 +484,7 @@ def create_users_with_list_input_with_http_info(self, user : Annotated[List[User collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def delete_user(self, username : Annotated[StrictStr, Field(description="The name that needs to be deleted")], **kwargs) -> None: # noqa: E501 """Delete user # noqa: E501 @@ -514,7 +514,7 @@ def delete_user(self, username : Annotated[StrictStr, Field(description="The nam raise ValueError(message) return self.delete_user_with_http_info(username, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def delete_user_with_http_info(self, username : Annotated[StrictStr, Field(description="The name that needs to be deleted")], **kwargs) -> ApiResponse: # noqa: E501 """Delete user # noqa: E501 @@ -618,7 +618,7 @@ def delete_user_with_http_info(self, username : Annotated[StrictStr, Field(descr collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def get_user_by_name(self, username : Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> User: # noqa: E501 """Get user by user name # noqa: E501 @@ -648,7 +648,7 @@ def get_user_by_name(self, username : Annotated[StrictStr, Field(description="Th raise ValueError(message) return self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def get_user_by_name_with_http_info(self, username : Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")], **kwargs) -> ApiResponse: # noqa: E501 """Get user by user name # noqa: E501 @@ -760,7 +760,7 @@ def get_user_by_name_with_http_info(self, username : Annotated[StrictStr, Field( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def login_user(self, username : Annotated[StrictStr, Field(description="The user name for login")], password : Annotated[StrictStr, Field(description="The password for login in clear text")], **kwargs) -> str: # noqa: E501 """Logs user into the system # noqa: E501 @@ -792,7 +792,7 @@ def login_user(self, username : Annotated[StrictStr, Field(description="The user raise ValueError(message) return self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def login_user_with_http_info(self, username : Annotated[StrictStr, Field(description="The user name for login")], password : Annotated[StrictStr, Field(description="The password for login in clear text")], **kwargs) -> ApiResponse: # noqa: E501 """Logs user into the system # noqa: E501 @@ -909,7 +909,7 @@ def login_user_with_http_info(self, username : Annotated[StrictStr, Field(descri collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def logout_user(self, **kwargs) -> None: # noqa: E501 """Logs out current logged in user session # noqa: E501 @@ -937,7 +937,7 @@ def logout_user(self, **kwargs) -> None: # noqa: E501 raise ValueError(message) return self.logout_user_with_http_info(**kwargs) # noqa: E501 - @validate_arguments + @validate_call def logout_user_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 """Logs out current logged in user session # noqa: E501 @@ -1035,7 +1035,7 @@ def logout_user_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) - @validate_arguments + @validate_call def update_user(self, username : Annotated[StrictStr, Field(description="name that need to be deleted")], user : Annotated[User, Field(description="Updated user object")], **kwargs) -> None: # noqa: E501 """Updated user # noqa: E501 @@ -1067,7 +1067,7 @@ def update_user(self, username : Annotated[StrictStr, Field(description="name th raise ValueError(message) return self.update_user_with_http_info(username, user, **kwargs) # noqa: E501 - @validate_arguments + @validate_call def update_user_with_http_info(self, username : Annotated[StrictStr, Field(description="name that need to be deleted")], user : Annotated[User, Field(description="Updated user object")], **kwargs) -> ApiResponse: # noqa: E501 """Updated user # noqa: E501 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 28de0a95be08..1be3065d20f2 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesAnyType(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType: return None if not isinstance(obj, dict): - return AdditionalPropertiesAnyType.parse_obj(obj) + return AdditionalPropertiesAnyType.model_validate(obj) - _obj = AdditionalPropertiesAnyType.parse_obj({ + _obj = AdditionalPropertiesAnyType.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 4ce0f54e3535..70e633cdd215 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 @@ -30,14 +30,15 @@ class AdditionalPropertiesClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["map_property", "map_of_map_property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: return None if not isinstance(obj, dict): - return AdditionalPropertiesClass.parse_obj(obj) + return AdditionalPropertiesClass.model_validate(obj) - _obj = AdditionalPropertiesClass.parse_obj({ + _obj = AdditionalPropertiesClass.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 9d9b105a9318..c401cd724c55 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesObject: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesObject: return None if not isinstance(obj, dict): - return AdditionalPropertiesObject.parse_obj(obj) + return AdditionalPropertiesObject.model_validate(obj) - _obj = AdditionalPropertiesObject.parse_obj({ + _obj = AdditionalPropertiesObject.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 4327f030ce20..546c5774950a 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 @@ -29,14 +29,15 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> AdditionalPropertiesWithDescriptionOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesWithDescriptionOnly: return None if not isinstance(obj, dict): - return AdditionalPropertiesWithDescriptionOnly.parse_obj(obj) + return AdditionalPropertiesWithDescriptionOnly.model_validate(obj) - _obj = AdditionalPropertiesWithDescriptionOnly.parse_obj({ + _obj = AdditionalPropertiesWithDescriptionOnly.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 91decaece896..d88e6480c91b 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 @@ -32,14 +32,15 @@ class AllOfWithSingleRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["username", "SingleRefType"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> AllOfWithSingleRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -72,9 +73,9 @@ def from_dict(cls, obj: dict) -> AllOfWithSingleRef: return None if not isinstance(obj, dict): - return AllOfWithSingleRef.parse_obj(obj) + return AllOfWithSingleRef.model_validate(obj) - _obj = AllOfWithSingleRef.parse_obj({ + _obj = AllOfWithSingleRef.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 b74a4ca73e00..e5c95fef232e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -31,10 +31,11 @@ class Animal(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "color"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + # JSON field name that stores the object type __discriminator_property_name = 'className' @@ -56,7 +57,7 @@ def get_discriminator_value(cls, obj: dict) -> str: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -70,7 +71,7 @@ def from_json(cls, json_str: str) -> Union(Cat, Dog): def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, 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 397956daa536..23097a497506 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -34,9 +34,9 @@ class AnyOfColor(BaseModel): """ # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.") + anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") + anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") # data type: str anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") if TYPE_CHECKING: @@ -45,8 +45,9 @@ class AnyOfColor(BaseModel): actual_instance: Any = None any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } def __init__(self, *args, **kwargs) -> None: if args: @@ -58,9 +59,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.construct() + instance = AnyOfColor.model_construct() error_messages = [] # validate data type: List[int] try: @@ -93,7 +94,7 @@ def from_dict(cls, obj: dict) -> AnyOfColor: @classmethod def from_json(cls, json_str: str) -> AnyOfColor: """Returns the object represented by the json string""" - instance = AnyOfColor.construct() + instance = AnyOfColor.model_construct() error_messages = [] # deserialize data into List[int] try: @@ -153,6 +154,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 174c3af2554a..00369b878bd3 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -43,8 +43,9 @@ class AnyOfPig(BaseModel): actual_instance: Any = None any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS] - class Config: - validate_assignment = True + model_config = { + "validate_assignment": True + } def __init__(self, *args, **kwargs) -> None: if args: @@ -56,9 +57,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.construct() + instance = AnyOfPig.model_construct() error_messages = [] # validate data type: BasquePig if not isinstance(v, BasquePig): @@ -85,7 +86,7 @@ def from_dict(cls, obj: dict) -> AnyOfPig: @classmethod def from_json(cls, json_str: str) -> AnyOfPig: """Returns the object represented by the json string""" - instance = AnyOfPig.construct() + instance = AnyOfPig.model_construct() error_messages = [] # anyof_schema_1_validator: Optional[BasquePig] = None try: @@ -130,6 +131,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 36a02f575e1b..a08e764c93b5 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 @@ -31,14 +31,15 @@ class ApiResponse(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["code", "type", "message"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> ApiResponse: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> ApiResponse: return None if not isinstance(obj, dict): - return ApiResponse.parse_obj(obj) + return ApiResponse.model_validate(obj) - _obj = ApiResponse.parse_obj({ + _obj = ApiResponse.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 14d0f3e597fe..c242a481e59b 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 @@ -30,14 +30,15 @@ class ArrayOfArrayOfModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["another_property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ArrayOfArrayOfModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -79,9 +80,9 @@ def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: return None if not isinstance(obj, dict): - return ArrayOfArrayOfModel.parse_obj(obj) + return ArrayOfArrayOfModel.model_validate(obj) - _obj = ArrayOfArrayOfModel.parse_obj({ + _obj = ArrayOfArrayOfModel.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 105251703fa5..d2f8b48a1b49 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 @@ -30,14 +30,15 @@ class ArrayOfArrayOfNumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["ArrayArrayNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ArrayOfArrayOfNumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ArrayOfArrayOfNumberOnly: return None if not isinstance(obj, dict): - return ArrayOfArrayOfNumberOnly.parse_obj(obj) + return ArrayOfArrayOfNumberOnly.model_validate(obj) - _obj = ArrayOfArrayOfNumberOnly.parse_obj({ + _obj = ArrayOfArrayOfNumberOnly.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 7ae38c86ee9b..7b013a257cd6 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 @@ -30,14 +30,15 @@ class ArrayOfNumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["ArrayNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ArrayOfNumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ArrayOfNumberOnly: return None if not isinstance(obj, dict): - return ArrayOfNumberOnly.parse_obj(obj) + return ArrayOfNumberOnly.model_validate(obj) - _obj = ArrayOfNumberOnly.parse_obj({ + _obj = ArrayOfNumberOnly.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 0e920799b488..028329d774a6 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 @@ -28,20 +28,21 @@ class ArrayTest(BaseModel): """ ArrayTest """ - array_of_string: Optional[Annotated[List[StrictStr], Field(min_items=0, max_items=3)]] = None + array_of_string: Optional[Annotated[List[StrictStr], Field(min_length=0, max_length=3)]] = None array_array_of_integer: Optional[List[List[StrictInt]]] = None array_array_of_model: Optional[List[List[ReadOnlyFirst]]] = None additional_properties: Dict[str, Any] = {} __properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -55,7 +56,7 @@ def from_json(cls, json_str: str) -> ArrayTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -83,9 +84,9 @@ def from_dict(cls, obj: dict) -> ArrayTest: return None if not isinstance(obj, dict): - return ArrayTest.parse_obj(obj) + return ArrayTest.model_validate(obj) - _obj = ArrayTest.parse_obj({ + _obj = ArrayTest.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 c9e9b981cc3a..c107ca3b05ca 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 @@ -31,14 +31,15 @@ class BasquePig(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "color"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> BasquePig: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> BasquePig: return None if not isinstance(obj, dict): - return BasquePig.parse_obj(obj) + return BasquePig.model_validate(obj) - _obj = BasquePig.parse_obj({ + _obj = BasquePig.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 9d20b2aea6a4..96466c378060 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -35,14 +35,15 @@ class Capitalization(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -56,7 +57,7 @@ def from_json(cls, json_str: str) -> Capitalization: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -75,9 +76,9 @@ def from_dict(cls, obj: dict) -> Capitalization: return None if not isinstance(obj, dict): - return Capitalization.parse_obj(obj) + return Capitalization.model_validate(obj) - _obj = Capitalization.parse_obj({ + _obj = Capitalization.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 0deedf9e6163..e3f7c2a6ea51 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -30,14 +30,15 @@ class Cat(Animal): additional_properties: Dict[str, Any] = {} __properties = ["className", "color", "declawed"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Cat: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> Cat: return None if not isinstance(obj, dict): - return Cat.parse_obj(obj) + return Cat.model_validate(obj) - _obj = Cat.parse_obj({ + _obj = Cat.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 ffe0ad7b5770..6dcba4df529d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -30,14 +30,15 @@ class Category(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Category: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> Category: return None if not isinstance(obj, dict): - return Category.parse_obj(obj) + return Category.model_validate(obj) - _obj = Category.parse_obj({ + _obj = Category.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 f9f28e8eebe9..a1e6b9075495 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 @@ -30,14 +30,15 @@ class CircularReferenceModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> CircularReferenceModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> CircularReferenceModel: return None if not isinstance(obj, dict): - return CircularReferenceModel.parse_obj(obj) + return CircularReferenceModel.model_validate(obj) - _obj = CircularReferenceModel.parse_obj({ + _obj = CircularReferenceModel.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 b94d9174bbb4..d8e9f2252efe 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 @@ -30,14 +30,15 @@ class ClassModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["_class"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ClassModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ClassModel: return None if not isinstance(obj, dict): - return ClassModel.parse_obj(obj) + return ClassModel.model_validate(obj) - _obj = ClassModel.parse_obj({ + _obj = ClassModel.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 689c62313b62..278f76d80bc3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -29,14 +29,15 @@ class Client(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["client"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Client: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> Client: return None if not isinstance(obj, dict): - return Client.parse_obj(obj) + return Client.model_validate(obj) - _obj = Client.parse_obj({ + _obj = Client.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 d6b2ab8d8d76..2fdc7e8805cf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -33,16 +33,18 @@ class Color(BaseModel): RGB array, RGBA array, or hex string. """ # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=3, max_items=3)]] = Field(default=None, description="RGB three element array with values 0-255.") + oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_items=4, max_items=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") + oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") # data type: str oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: List[str] = Literal[COLOR_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["List[int]", "str"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -54,12 +56,12 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): if v is None: return v - instance = Color.construct() + instance = Color.model_construct() error_messages = [] match = 0 # validate data type: List[int] @@ -96,7 +98,7 @@ def from_dict(cls, obj: dict) -> Color: @classmethod def from_json(cls, json_str: str) -> Color: """Returns the object represented by the json string""" - instance = Color.construct() + instance = Color.model_construct() if json_str is None: return instance @@ -165,6 +167,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 16e389db1df4..1ed187ed4596 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -31,14 +31,15 @@ class Creature(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["info", "type"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> Creature: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -74,9 +75,9 @@ def from_dict(cls, obj: dict) -> Creature: return None if not isinstance(obj, dict): - return Creature.parse_obj(obj) + return Creature.model_validate(obj) - _obj = Creature.parse_obj({ + _obj = Creature.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 76afde1837c5..7c8c96572547 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 @@ -29,14 +29,15 @@ class CreatureInfo(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> CreatureInfo: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> CreatureInfo: return None if not isinstance(obj, dict): - return CreatureInfo.parse_obj(obj) + return CreatureInfo.model_validate(obj) - _obj = CreatureInfo.parse_obj({ + _obj = CreatureInfo.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 3cd1f2d70a24..6ba8851e8dd2 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 @@ -31,14 +31,15 @@ class DanishPig(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["className", "size"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> DanishPig: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> DanishPig: return None if not isinstance(obj, dict): - return DanishPig.parse_obj(obj) + return DanishPig.model_validate(obj) - _obj = DanishPig.parse_obj({ + _obj = DanishPig.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 ef03024d9639..3a283d11bce0 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 @@ -29,14 +29,15 @@ class DeprecatedObject(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> DeprecatedObject: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> DeprecatedObject: return None if not isinstance(obj, dict): - return DeprecatedObject.parse_obj(obj) + return DeprecatedObject.model_validate(obj) - _obj = DeprecatedObject.parse_obj({ + _obj = DeprecatedObject.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 78ae72f04033..a6f8a6d23ccd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -30,14 +30,15 @@ class Dog(Animal): additional_properties: Dict[str, Any] = {} __properties = ["className", "color", "breed"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Dog: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> Dog: return None if not isinstance(obj, dict): - return Dog.parse_obj(obj) + return Dog.model_validate(obj) - _obj = Dog.parse_obj({ + _obj = Dog.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 de7b64212434..42bed2afa374 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 @@ -30,14 +30,15 @@ class DummyModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "self_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> DummyModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> DummyModel: return None if not isinstance(obj, dict): - return DummyModel.parse_obj(obj) + return DummyModel.model_validate(obj) - _obj = DummyModel.parse_obj({ + _obj = DummyModel.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 620c94be60bf..1af1ef9c00d3 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, List, Optional -from pydantic import BaseModel, StrictStr, validator +from pydantic import BaseModel, StrictStr, field_validator class EnumArrays(BaseModel): """ @@ -30,7 +30,7 @@ class EnumArrays(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["just_symbol", "array_enum"] - @validator('just_symbol') + @field_validator('just_symbol') def just_symbol_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -40,7 +40,7 @@ def just_symbol_validate_enum(cls, value): raise ValueError("must be one of enum values ('>=', '$')") return value - @validator('array_enum') + @field_validator('array_enum') def array_enum_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -51,14 +51,15 @@ def array_enum_validate_enum(cls, value): raise ValueError("each list item must be one of ('fish', 'crab')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -72,7 +73,7 @@ def from_json(cls, json_str: str) -> EnumArrays: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -91,9 +92,9 @@ def from_dict(cls, obj: dict) -> EnumArrays: return None if not isinstance(obj, dict): - return EnumArrays.parse_obj(obj) + return EnumArrays.model_validate(obj) - _obj = EnumArrays.parse_obj({ + _obj = EnumArrays.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_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 9398f6bbc4b5..937a10fcc5ea 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictFloat, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictFloat, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue @@ -42,7 +42,7 @@ class EnumTest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"] - @validator('enum_string') + @field_validator('enum_string') def enum_string_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -52,14 +52,14 @@ def enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value - @validator('enum_string_required') + @field_validator('enum_string_required') def enum_string_required_validate_enum(cls, value): """Validates the enum""" if value not in ('UPPER', 'lower', ''): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value - @validator('enum_integer_default') + @field_validator('enum_integer_default') def enum_integer_default_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -69,7 +69,7 @@ def enum_integer_default_validate_enum(cls, value): raise ValueError("must be one of enum values (1, 5, 14)") return value - @validator('enum_integer') + @field_validator('enum_integer') def enum_integer_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -79,7 +79,7 @@ def enum_integer_validate_enum(cls, value): raise ValueError("must be one of enum values (1, -1)") return value - @validator('enum_number') + @field_validator('enum_number') def enum_number_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -89,14 +89,15 @@ def enum_number_validate_enum(cls, value): raise ValueError("must be one of enum values (1.1, -1.2)") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -110,7 +111,7 @@ def from_json(cls, json_str: str) -> EnumTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -121,8 +122,8 @@ def to_dict(self): _dict[_key] = _value # set to None if outer_enum (nullable) is None - # and __fields_set__ contains the field - if self.outer_enum is None and "outer_enum" in self.__fields_set__: + # and model_fields_set contains the field + if self.outer_enum is None and "outer_enum" in self.model_fields_set: _dict['outerEnum'] = None return _dict @@ -134,9 +135,9 @@ def from_dict(cls, obj: dict) -> EnumTest: return None if not isinstance(obj, dict): - return EnumTest.parse_obj(obj) + return EnumTest.model_validate(obj) - _obj = EnumTest.parse_obj({ + _obj = EnumTest.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 114b01da18f2..80b1564e58f5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -30,14 +30,15 @@ class File(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["sourceURI"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> File: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> File: return None if not isinstance(obj, dict): - return File.parse_obj(obj) + return File.model_validate(obj) - _obj = File.parse_obj({ + _obj = File.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 517980f5f447..030d9f29edbd 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 @@ -31,14 +31,15 @@ class FileSchemaTestClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["file", "files"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> FileSchemaTestClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -81,9 +82,9 @@ def from_dict(cls, obj: dict) -> FileSchemaTestClass: return None if not isinstance(obj, dict): - return FileSchemaTestClass.parse_obj(obj) + return FileSchemaTestClass.model_validate(obj) - _obj = FileSchemaTestClass.parse_obj({ + _obj = FileSchemaTestClass.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 070aa2b57773..900034234a4b 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 @@ -30,14 +30,15 @@ class FirstRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "self_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> FirstRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> FirstRef: return None if not isinstance(obj, dict): - return FirstRef.parse_obj(obj) + return FirstRef.model_validate(obj) - _obj = FirstRef.parse_obj({ + _obj = FirstRef.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 89fede0ee271..cacb692da0c7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -29,14 +29,15 @@ class Foo(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Foo: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> Foo: return None if not isinstance(obj, dict): - return Foo.parse_obj(obj) + return Foo.model_validate(obj) - _obj = Foo.parse_obj({ + _obj = Foo.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 006d85181ae8..ac6ef75e60bc 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 @@ -30,14 +30,15 @@ class FooGetDefaultResponse(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["string"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> FooGetDefaultResponse: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> FooGetDefaultResponse: return None if not isinstance(obj, dict): - return FooGetDefaultResponse.parse_obj(obj) + return FooGetDefaultResponse.model_validate(obj) - _obj = FooGetDefaultResponse.parse_obj({ + _obj = FooGetDefaultResponse.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 06392e44329a..e383796a98fb 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 @@ -19,7 +19,7 @@ from datetime import date, datetime from typing import Any, Dict, Optional, Union -from pydantic import BaseModel, StrictBytes, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictBytes, StrictInt, StrictStr, field_validator from decimal import Decimal from pydantic import Field from typing_extensions import Annotated @@ -47,7 +47,7 @@ class FormatTest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["integer", "int32", "int64", "number", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"] - @validator('string') + @field_validator('string') def string_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -57,7 +57,7 @@ def string_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /[a-z]/i") return value - @validator('string_with_double_quote_pattern') + @field_validator('string_with_double_quote_pattern') def string_with_double_quote_pattern_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -67,7 +67,7 @@ def string_with_double_quote_pattern_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /this is \"something\"/") return value - @validator('pattern_with_digits') + @field_validator('pattern_with_digits') def pattern_with_digits_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -77,7 +77,7 @@ def pattern_with_digits_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^\d{10}$/") return value - @validator('pattern_with_digits_and_delimiter') + @field_validator('pattern_with_digits_and_delimiter') def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -87,14 +87,15 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^image_\d{1,3}$/i") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -108,7 +109,7 @@ def from_json(cls, json_str: str) -> FormatTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -127,9 +128,9 @@ def from_dict(cls, obj: dict) -> FormatTest: return None if not isinstance(obj, dict): - return FormatTest.parse_obj(obj) + return FormatTest.model_validate(obj) - _obj = FormatTest.parse_obj({ + _obj = FormatTest.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 e0612dbaab25..50af5287e1ad 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 @@ -30,14 +30,15 @@ class HasOnlyReadOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar", "foo"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> HasOnlyReadOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "bar", "foo", @@ -72,9 +73,9 @@ def from_dict(cls, obj: dict) -> HasOnlyReadOnly: return None if not isinstance(obj, dict): - return HasOnlyReadOnly.parse_obj(obj) + return HasOnlyReadOnly.model_validate(obj) - _obj = HasOnlyReadOnly.parse_obj({ + _obj = HasOnlyReadOnly.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 97ea8c9e8b47..bcb06ace99c7 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 @@ -30,14 +30,15 @@ class HealthCheckResult(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["NullableMessage"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> HealthCheckResult: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -62,8 +63,8 @@ def to_dict(self): _dict[_key] = _value # set to None if nullable_message (nullable) is None - # and __fields_set__ contains the field - if self.nullable_message is None and "nullable_message" in self.__fields_set__: + # and model_fields_set contains the field + if self.nullable_message is None and "nullable_message" in self.model_fields_set: _dict['NullableMessage'] = None return _dict @@ -75,9 +76,9 @@ def from_dict(cls, obj: dict) -> HealthCheckResult: return None if not isinstance(obj, dict): - return HealthCheckResult.parse_obj(obj) + return HealthCheckResult.model_validate(obj) - _obj = HealthCheckResult.parse_obj({ + _obj = HealthCheckResult.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 56ba51211585..e53b2401dd7f 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 @@ -30,14 +30,15 @@ class InnerDictWithProperty(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["aProperty"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> InnerDictWithProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> InnerDictWithProperty: return None if not isinstance(obj, dict): - return InnerDictWithProperty.parse_obj(obj) + return InnerDictWithProperty.model_validate(obj) - _obj = InnerDictWithProperty.parse_obj({ + _obj = InnerDictWithProperty.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 a292b747c56c..0fb43ecaebb3 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from pydantic import Field from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class IntOrString(BaseModel): # data type: str oneof_schema_2_validator: Optional[StrictStr] = None actual_instance: Optional[Union[int, str]] = None - one_of_schemas: List[str] = Literal[INTORSTRING_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["int", "str"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -52,9 +54,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.construct() + instance = IntOrString.model_construct() error_messages = [] match = 0 # validate data type: int @@ -85,7 +87,7 @@ def from_dict(cls, obj: dict) -> IntOrString: @classmethod def from_json(cls, json_str: str) -> IntOrString: """Returns the object represented by the json string""" - instance = IntOrString.construct() + instance = IntOrString.model_construct() error_messages = [] match = 0 @@ -142,6 +144,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 80236c059e6f..2d1ca0f6cff1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list.py @@ -30,14 +30,15 @@ class List(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["123-list"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> List: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> List: return None if not isinstance(obj, dict): - return List.parse_obj(obj) + return List.model_validate(obj) - _obj = List.parse_obj({ + _obj = List.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 eeece98926ee..f33be2c87f49 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 @@ -31,14 +31,15 @@ class MapOfArrayOfModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["shopIdToOrgOnlineLipMap"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> MapOfArrayOfModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -80,9 +81,9 @@ def from_dict(cls, obj: dict) -> MapOfArrayOfModel: return None if not isinstance(obj, dict): - return MapOfArrayOfModel.parse_obj(obj) + return MapOfArrayOfModel.model_validate(obj) - _obj = MapOfArrayOfModel.parse_obj({ + _obj = MapOfArrayOfModel.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 d34257aa9963..e08eb788b98d 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictBool, StrictStr, validator +from pydantic import BaseModel, StrictBool, StrictStr, field_validator class MapTest(BaseModel): """ @@ -32,7 +32,7 @@ class MapTest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] - @validator('map_of_enum_string') + @field_validator('map_of_enum_string') def map_of_enum_string_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -42,14 +42,15 @@ def map_of_enum_string_validate_enum(cls, value): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -63,7 +64,7 @@ def from_json(cls, json_str: str) -> MapTest: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -82,9 +83,9 @@ def from_dict(cls, obj: dict) -> MapTest: return None if not isinstance(obj, dict): - return MapTest.parse_obj(obj) + return MapTest.model_validate(obj) - _obj = MapTest.parse_obj({ + _obj = MapTest.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 901935866db3..fba7f02172ad 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 @@ -33,14 +33,15 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["uuid", "dateTime", "map"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> MixedPropertiesAndAdditionalPropertiesClass def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -80,9 +81,9 @@ def from_dict(cls, obj: dict) -> MixedPropertiesAndAdditionalPropertiesClass: return None if not isinstance(obj, dict): - return MixedPropertiesAndAdditionalPropertiesClass.parse_obj(obj) + return MixedPropertiesAndAdditionalPropertiesClass.model_validate(obj) - _obj = MixedPropertiesAndAdditionalPropertiesClass.parse_obj({ + _obj = MixedPropertiesAndAdditionalPropertiesClass.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 ddc1f9f96192..f5818228991c 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 @@ -31,14 +31,15 @@ class Model200Response(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name", "class"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> Model200Response: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> Model200Response: return None if not isinstance(obj, dict): - return Model200Response.parse_obj(obj) + return Model200Response.model_validate(obj) - _obj = Model200Response.parse_obj({ + _obj = Model200Response.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 3d9922adcf7d..d39ad5cb6bdf 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 @@ -30,14 +30,15 @@ class ModelReturn(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["return"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ModelReturn: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ModelReturn: return None if not isinstance(obj, dict): - return ModelReturn.parse_obj(obj) + return ModelReturn.model_validate(obj) - _obj = ModelReturn.parse_obj({ + _obj = ModelReturn.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 8f2e407b7d15..5b4739037295 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -33,14 +33,15 @@ class Name(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["name", "snake_case", "property", "123Number"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> Name: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "snake_case", "var_123_number", @@ -75,9 +76,9 @@ def from_dict(cls, obj: dict) -> Name: return None if not isinstance(obj, dict): - return Name.parse_obj(obj) + return Name.model_validate(obj) - _obj = Name.parse_obj({ + _obj = Name.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 bc6e96d321f2..4c46cc2ae231 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 @@ -41,14 +41,15 @@ class NullableClass(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -62,7 +63,7 @@ def from_json(cls, json_str: str) -> NullableClass: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,58 +74,58 @@ def to_dict(self): _dict[_key] = _value # set to None if required_integer_prop (nullable) is None - # and __fields_set__ contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: _dict['required_integer_prop'] = None # set to None if integer_prop (nullable) is None - # and __fields_set__ contains the field - if self.integer_prop is None and "integer_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.integer_prop is None and "integer_prop" in self.model_fields_set: _dict['integer_prop'] = None # set to None if number_prop (nullable) is None - # and __fields_set__ contains the field - if self.number_prop is None and "number_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.number_prop is None and "number_prop" in self.model_fields_set: _dict['number_prop'] = None # set to None if boolean_prop (nullable) is None - # and __fields_set__ contains the field - if self.boolean_prop is None and "boolean_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: _dict['boolean_prop'] = None # set to None if string_prop (nullable) is None - # and __fields_set__ contains the field - if self.string_prop is None and "string_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.string_prop is None and "string_prop" in self.model_fields_set: _dict['string_prop'] = None # set to None if date_prop (nullable) is None - # and __fields_set__ contains the field - if self.date_prop is None and "date_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.date_prop is None and "date_prop" in self.model_fields_set: _dict['date_prop'] = None # set to None if datetime_prop (nullable) is None - # and __fields_set__ contains the field - if self.datetime_prop is None and "datetime_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: _dict['datetime_prop'] = None # set to None if array_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: _dict['array_nullable_prop'] = None # set to None if array_and_items_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: _dict['array_and_items_nullable_prop'] = None # set to None if object_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: _dict['object_nullable_prop'] = None # set to None if object_and_items_nullable_prop (nullable) is None - # and __fields_set__ contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.__fields_set__: + # and model_fields_set contains the field + if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: _dict['object_and_items_nullable_prop'] = None return _dict @@ -136,9 +137,9 @@ def from_dict(cls, obj: dict) -> NullableClass: return None if not isinstance(obj, dict): - return NullableClass.parse_obj(obj) + return NullableClass.model_validate(obj) - _obj = NullableClass.parse_obj({ + _obj = NullableClass.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 008daec1b4d0..9feb0a3f0a08 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictInt, validator +from pydantic import BaseModel, StrictInt, field_validator from pydantic import Field from typing_extensions import Annotated @@ -32,7 +32,7 @@ class NullableProperty(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] - @validator('name') + @field_validator('name') def name_validate_regular_expression(cls, value): """Validates the regular expression""" if value is None: @@ -42,14 +42,15 @@ def name_validate_regular_expression(cls, value): raise ValueError(r"must validate the regular expression /^[A-Z].*/") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -63,7 +64,7 @@ def from_json(cls, json_str: str) -> NullableProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -74,8 +75,8 @@ def to_dict(self): _dict[_key] = _value # set to None if name (nullable) is None - # and __fields_set__ contains the field - if self.name is None and "name" in self.__fields_set__: + # and model_fields_set contains the field + if self.name is None and "name" in self.model_fields_set: _dict['name'] = None return _dict @@ -87,9 +88,9 @@ def from_dict(cls, obj: dict) -> NullableProperty: return None if not isinstance(obj, dict): - return NullableProperty.parse_obj(obj) + return NullableProperty.model_validate(obj) - _obj = NullableProperty.parse_obj({ + _obj = NullableProperty.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 0885acb8432a..845ec245db68 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 @@ -30,14 +30,15 @@ class NumberOnly(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["JustNumber"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> NumberOnly: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> NumberOnly: return None if not isinstance(obj, dict): - return NumberOnly.parse_obj(obj) + return NumberOnly.model_validate(obj) - _obj = NumberOnly.parse_obj({ + _obj = NumberOnly.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 2d89ae37c466..30d264be3ac5 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 @@ -30,14 +30,15 @@ class ObjectToTestAdditionalProperties(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["property"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ObjectToTestAdditionalProperties: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> ObjectToTestAdditionalProperties: return None if not isinstance(obj, dict): - return ObjectToTestAdditionalProperties.parse_obj(obj) + return ObjectToTestAdditionalProperties.model_validate(obj) - _obj = ObjectToTestAdditionalProperties.parse_obj({ + _obj = ObjectToTestAdditionalProperties.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 736478dc831e..a37a6415a925 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 @@ -34,14 +34,15 @@ class ObjectWithDeprecatedFields(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["uuid", "id", "deprecatedRef", "bars"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -55,7 +56,7 @@ def from_json(cls, json_str: str) -> ObjectWithDeprecatedFields: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -77,9 +78,9 @@ def from_dict(cls, obj: dict) -> ObjectWithDeprecatedFields: return None if not isinstance(obj, dict): - return ObjectWithDeprecatedFields.parse_obj(obj) + return ObjectWithDeprecatedFields.model_validate(obj) - _obj = ObjectWithDeprecatedFields.parse_obj({ + _obj = ObjectWithDeprecatedFields.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 dfc27aa88200..65067fe7620e 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 @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class OneOfEnumString(BaseModel): # data type: EnumString2 oneof_schema_2_validator: Optional[EnumString2] = None actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: List[str] = Literal[ONEOFENUMSTRING_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True def __init__(self, *args, **kwargs) -> None: if args: @@ -52,9 +54,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = OneOfEnumString.construct() + instance = OneOfEnumString.model_construct() error_messages = [] match = 0 # validate data type: EnumString1 @@ -83,7 +85,7 @@ def from_dict(cls, obj: dict) -> OneOfEnumString: @classmethod def from_json(cls, json_str: str) -> OneOfEnumString: """Returns the object represented by the json string""" - instance = OneOfEnumString.construct() + instance = OneOfEnumString.model_construct() error_messages = [] match = 0 @@ -134,6 +136,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 e5386fd01eb2..9a082803f8cf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -19,7 +19,7 @@ from datetime import datetime from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, field_validator from pydantic import Field class Order(BaseModel): @@ -35,7 +35,7 @@ class Order(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "petId", "quantity", "shipDate", "status", "complete"] - @validator('status') + @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -45,14 +45,15 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -66,7 +67,7 @@ def from_json(cls, json_str: str) -> Order: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -85,9 +86,9 @@ def from_dict(cls, obj: dict) -> Order: return None if not isinstance(obj, dict): - return Order.parse_obj(obj) + return Order.model_validate(obj) - _obj = Order.parse_obj({ + _obj = Order.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 30f3280d2814..5b85be74ab97 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 @@ -31,14 +31,15 @@ class OuterComposite(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["my_number", "my_string", "my_boolean"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> OuterComposite: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> OuterComposite: return None if not isinstance(obj, dict): - return OuterComposite.parse_obj(obj) + return OuterComposite.model_validate(obj) - _obj = OuterComposite.parse_obj({ + _obj = OuterComposite.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_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index b8f15909e725..fe073e3cc8c5 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 @@ -32,14 +32,15 @@ class OuterObjectWithEnumProperty(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["str_value", "value"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> OuterObjectWithEnumProperty: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -64,8 +65,8 @@ def to_dict(self): _dict[_key] = _value # set to None if str_value (nullable) is None - # and __fields_set__ contains the field - if self.str_value is None and "str_value" in self.__fields_set__: + # and model_fields_set contains the field + if self.str_value is None and "str_value" in self.model_fields_set: _dict['str_value'] = None return _dict @@ -77,9 +78,9 @@ def from_dict(cls, obj: dict) -> OuterObjectWithEnumProperty: return None if not isinstance(obj, dict): - return OuterObjectWithEnumProperty.parse_obj(obj) + return OuterObjectWithEnumProperty.model_validate(obj) - _obj = OuterObjectWithEnumProperty.parse_obj({ + _obj = OuterObjectWithEnumProperty.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 4df17374dc10..3f92a9bdc3d5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -31,14 +31,15 @@ class Parent(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["optionalDict"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> Parent: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -78,9 +79,9 @@ def from_dict(cls, obj: dict) -> Parent: return None if not isinstance(obj, dict): - return Parent.parse_obj(obj) + return Parent.model_validate(obj) - _obj = Parent.parse_obj({ + _obj = Parent.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 902c2558f1cc..54f687f1ea29 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 @@ -31,14 +31,15 @@ class ParentWithOptionalDict(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["optionalDict"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -52,7 +53,7 @@ def from_json(cls, json_str: str) -> ParentWithOptionalDict: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -78,9 +79,9 @@ def from_dict(cls, obj: dict) -> ParentWithOptionalDict: return None if not isinstance(obj, dict): - return ParentWithOptionalDict.parse_obj(obj) + return ParentWithOptionalDict.model_validate(obj) - _obj = ParentWithOptionalDict.parse_obj({ + _obj = ParentWithOptionalDict.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 6242c5ead08f..d79d9c94df51 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -19,7 +19,7 @@ from typing import Any, Dict, List, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from typing_extensions import Annotated from petstore_api.models.category import Category @@ -32,13 +32,13 @@ class Pet(BaseModel): id: Optional[StrictInt] = None category: Optional[Category] = None name: StrictStr - photo_urls: Annotated[List[StrictStr], Field(min_items=0)] = Field(alias="photoUrls") + photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None status: Optional[StrictStr] = Field(default=None, description="pet status in the store") additional_properties: Dict[str, Any] = {} __properties = ["id", "category", "name", "photoUrls", "tags", "status"] - @validator('status') + @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -48,14 +48,15 @@ def status_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -69,7 +70,7 @@ def from_json(cls, json_str: str) -> Pet: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -98,9 +99,9 @@ def from_dict(cls, obj: dict) -> Pet: return None if not isinstance(obj, dict): - return Pet.parse_obj(obj) + return Pet.model_validate(obj) - _obj = Pet.parse_obj({ + _obj = Pet.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 d8c2fccc909e..341a4aed0f52 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -19,7 +19,7 @@ import re # noqa: F401 from typing import Any, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict @@ -37,10 +37,12 @@ class Pig(BaseModel): # data type: DanishPig oneof_schema_2_validator: Optional[DanishPig] = None actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: List[str] = Literal[PIG_ONE_OF_SCHEMAS] + one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + + model_config = { + "validate_assignment": True + } - class Config: - validate_assignment = True discriminator_value_class_map: Dict[str, str] = { } @@ -55,9 +57,9 @@ def __init__(self, *args, **kwargs) -> None: else: super().__init__(**kwargs) - @validator('actual_instance') + @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = Pig.construct() + instance = Pig.model_construct() error_messages = [] match = 0 # validate data type: BasquePig @@ -86,7 +88,7 @@ def from_dict(cls, obj: dict) -> Pig: @classmethod def from_json(cls, json_str: str) -> Pig: """Returns the object represented by the json string""" - instance = Pig.construct() + instance = Pig.model_construct() error_messages = [] match = 0 @@ -152,6 +154,6 @@ def to_dict(self) -> dict: def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) + return pprint.pformat(self.model_dump()) 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 96bfc4f51bdc..78d9f97a0262 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 @@ -32,14 +32,15 @@ class PropertyNameCollision(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["_type", "type", "type_"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -53,7 +54,7 @@ def from_json(cls, json_str: str) -> PropertyNameCollision: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -72,9 +73,9 @@ def from_dict(cls, obj: dict) -> PropertyNameCollision: return None if not isinstance(obj, dict): - return PropertyNameCollision.parse_obj(obj) + return PropertyNameCollision.model_validate(obj) - _obj = PropertyNameCollision.parse_obj({ + _obj = PropertyNameCollision.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 c5d5c86c59fd..581ecdf7b542 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 @@ -30,14 +30,15 @@ class ReadOnlyFirst(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["bar", "baz"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> ReadOnlyFirst: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "bar", "additional_properties" @@ -71,9 +72,9 @@ def from_dict(cls, obj: dict) -> ReadOnlyFirst: return None if not isinstance(obj, dict): - return ReadOnlyFirst.parse_obj(obj) + return ReadOnlyFirst.model_validate(obj) - _obj = ReadOnlyFirst.parse_obj({ + _obj = ReadOnlyFirst.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 2ce53c5f9232..286f39e4ae42 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 @@ -30,14 +30,15 @@ class SecondRef(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["category", "circular_ref"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> SecondRef: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> SecondRef: return None if not isinstance(obj, dict): - return SecondRef.parse_obj(obj) + return SecondRef.model_validate(obj) - _obj = SecondRef.parse_obj({ + _obj = SecondRef.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 9c5faa62f8c8..e1c51a1f23e7 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 @@ -30,14 +30,15 @@ class SelfReferenceModel(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> SelfReferenceModel: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -73,9 +74,9 @@ def from_dict(cls, obj: dict) -> SelfReferenceModel: return None if not isinstance(obj, dict): - return SelfReferenceModel.parse_obj(obj) + return SelfReferenceModel.model_validate(obj) - _obj = SelfReferenceModel.parse_obj({ + _obj = SelfReferenceModel.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/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index e2d87179a949..0cc61ec6bc36 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 @@ -30,14 +30,15 @@ class SpecialModelName(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["$special[property.name]"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> SpecialModelName: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> SpecialModelName: return None if not isinstance(obj, dict): - return SpecialModelName.parse_obj(obj) + return SpecialModelName.model_validate(obj) - _obj = SpecialModelName.parse_obj({ + _obj = SpecialModelName.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 3f7f6247b0c7..d44d2f4fb802 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 @@ -19,7 +19,7 @@ from typing import Any, Dict, Optional -from pydantic import BaseModel, StrictInt, StrictStr, validator +from pydantic import BaseModel, StrictInt, StrictStr, field_validator from pydantic import Field from petstore_api.models.category import Category @@ -33,7 +33,7 @@ class SpecialName(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["property", "async", "schema"] - @validator('var_schema') + @field_validator('var_schema') def var_schema_validate_enum(cls, value): """Validates the enum""" if value is None: @@ -43,14 +43,15 @@ def var_schema_validate_enum(cls, value): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -64,7 +65,7 @@ def from_json(cls, json_str: str) -> SpecialName: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -86,9 +87,9 @@ def from_dict(cls, obj: dict) -> SpecialName: return None if not isinstance(obj, dict): - return SpecialName.parse_obj(obj) + return SpecialName.model_validate(obj) - _obj = SpecialName.parse_obj({ + _obj = SpecialName.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 fcd5a0e716d3..378371978088 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -30,14 +30,15 @@ class Tag(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "name"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> Tag: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> Tag: return None if not isinstance(obj, dict): - return Tag.parse_obj(obj) + return Tag.model_validate(obj) - _obj = Tag.parse_obj({ + _obj = Tag.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 b7606b510af1..1ced9efa5f88 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 @@ -30,14 +30,15 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["someProperty"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -51,7 +52,7 @@ def from_json(cls, json_str: str) -> TestInlineFreeformAdditionalPropertiesReque def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -70,9 +71,9 @@ def from_dict(cls, obj: dict) -> TestInlineFreeformAdditionalPropertiesRequest: return None if not isinstance(obj, dict): - return TestInlineFreeformAdditionalPropertiesRequest.parse_obj(obj) + return TestInlineFreeformAdditionalPropertiesRequest.model_validate(obj) - _obj = TestInlineFreeformAdditionalPropertiesRequest.parse_obj({ + _obj = TestInlineFreeformAdditionalPropertiesRequest.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 522a3c94750c..647ac852dd48 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -29,14 +29,15 @@ class Tiger(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["skill"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -50,7 +51,7 @@ def from_json(cls, json_str: str) -> Tiger: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -69,9 +70,9 @@ def from_dict(cls, obj: dict) -> Tiger: return None if not isinstance(obj, dict): - return Tiger.parse_obj(obj) + return Tiger.model_validate(obj) - _obj = Tiger.parse_obj({ + _obj = Tiger.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 50df0f5072be..08330324388f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -37,14 +37,15 @@ class User(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -58,7 +59,7 @@ def from_json(cls, json_str: str) -> User: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -77,9 +78,9 @@ def from_dict(cls, obj: dict) -> User: return None if not isinstance(obj, dict): - return User.parse_obj(obj) + return User.model_validate(obj) - _obj = User.parse_obj({ + _obj = User.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 76c78c668bd9..3597922adb15 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 @@ -33,14 +33,15 @@ class WithNestedOneOf(BaseModel): additional_properties: Dict[str, Any] = {} __properties = ["size", "nested_pig", "nested_oneof_enum_string"] - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" @@ -54,7 +55,7 @@ def from_json(cls, json_str: str) -> WithNestedOneOf: def to_dict(self): """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, + _dict = self.model_dump(by_alias=True, exclude={ "additional_properties" }, @@ -79,9 +80,9 @@ def from_dict(cls, obj: dict) -> WithNestedOneOf: return None if not isinstance(obj, dict): - return WithNestedOneOf.parse_obj(obj) + return WithNestedOneOf.model_validate(obj) - _obj = WithNestedOneOf.parse_obj({ + _obj = WithNestedOneOf.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 03d7b222378c7faf62df891684babb8cbc7e5cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Fri, 29 Sep 2023 11:45:03 +0900 Subject: [PATCH 14/14] [python] fix typos in test cases --- .../client/petstore/python/tests/test_api_validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/openapi3/client/petstore/python/tests/test_api_validation.py b/samples/openapi3/client/petstore/python/tests/test_api_validation.py index ababab7cdd4b..035d618ce050 100644 --- a/samples/openapi3/client/petstore/python/tests/test_api_validation.py +++ b/samples/openapi3/client/petstore/python/tests/test_api_validation.py @@ -49,7 +49,7 @@ def test_set_param_validation(self): def test_required_param_validation(self): try: self.pet_api.get_pet_by_id() - except TypeError as e: + except ValidationError as e: self.assertIn("1 validation error for get_pet_by_id", str(e)) self.assertIn("Missing required argument", str(e))