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 4c00a2a8324..e035e4829b6 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -9,7 +9,7 @@ import re # noqa: F401 {{#vendorExtensions.x-py-model-imports}} {{{.}}} {{/vendorExtensions.x-py-model-imports}} -from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field @@ -28,7 +28,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Optional[Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Field(default=Literal[{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]) + any_of_schemas: Set[str] = { {{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}} } model_config = { "validate_assignment": True, 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 55d17ba8054..07a4d93f9dd 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -8,7 +8,7 @@ import pprint {{{.}}} {{/vendorExtensions.x-py-model-imports}} from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] @@ -22,7 +22,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] = Field(default=Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]) + one_of_schemas: Set[str] = { {{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}} } model_config = ConfigDict( validate_assignment=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 4dd958387d3..f6d277e7949 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 @@ -20,7 +20,7 @@ import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated -from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field @@ -41,7 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Optional[Union[List[int], str]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) + any_of_schemas: Set[str] = { "List[int]", "str" } model_config = { "validate_assignment": True, 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 5ff976e3cce..c949e136f41 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 @@ -21,7 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Optional 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 +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field @@ -40,7 +40,7 @@ class AnyOfPig(BaseModel): actual_instance: Optional[Union[BasquePig, DanishPig]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) + any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } model_config = { "validate_assignment": True, 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 0f89c3d81e3..bb740fb597d 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 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Any, List, Optional from typing_extensions import Annotated from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -35,7 +35,7 @@ class Color(BaseModel): # 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] = Field(default=Literal["List[int]", "str"]) + one_of_schemas: Set[str] = { "List[int]", "str" } model_config = ConfigDict( validate_assignment=True, 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 102540e15e1..f2a5a0a2d4a 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 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Any, List, Optional from typing_extensions import Annotated from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -33,7 +33,7 @@ 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] = Field(default=Literal["int", "str"]) + one_of_schemas: Set[str] = { "int", "str" } model_config = ConfigDict( validate_assignment=True, 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 27ab1abf97f..f180178737d 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 @@ -20,7 +20,7 @@ from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -34,7 +34,7 @@ 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] = Field(default=Literal["EnumString1", "EnumString2"]) + one_of_schemas: Set[str] = { "EnumString1", "EnumString2" } model_config = ConfigDict( validate_assignment=True, 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 7d4a9ae4671..b3a759e89b7 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 @@ -20,7 +20,7 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -34,7 +34,7 @@ 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] = Field(default=Literal["BasquePig", "DanishPig"]) + one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } model_config = ConfigDict( validate_assignment=True, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py index 9494a1a1167..cc1e1fc5a60 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -21,7 +21,7 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] @@ -37,7 +37,7 @@ class TaskActivity(BaseModel): # data type: Bathing oneof_schema_3_validator: Optional[Bathing] = None actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: List[str] = Field(default=Literal["Bathing", "Feeding", "PoopCleaning"]) + one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } model_config = ConfigDict( validate_assignment=True, 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 4dd958387d3..f6d277e7949 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 @@ -20,7 +20,7 @@ import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated -from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field @@ -41,7 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Optional[Union[List[int], str]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) + any_of_schemas: Set[str] = { "List[int]", "str" } model_config = { "validate_assignment": True, 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 5ff976e3cce..c949e136f41 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 @@ -21,7 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Optional 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 +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self from pydantic import Field @@ -40,7 +40,7 @@ class AnyOfPig(BaseModel): actual_instance: Optional[Union[BasquePig, DanishPig]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) + any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } model_config = { "validate_assignment": True, 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 0f89c3d81e3..bb740fb597d 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 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Any, List, Optional from typing_extensions import Annotated from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] @@ -35,7 +35,7 @@ class Color(BaseModel): # 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] = Field(default=Literal["List[int]", "str"]) + one_of_schemas: Set[str] = { "List[int]", "str" } model_config = ConfigDict( validate_assignment=True, 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 102540e15e1..f2a5a0a2d4a 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 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, f from typing import Any, List, Optional from typing_extensions import Annotated from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] @@ -33,7 +33,7 @@ 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] = Field(default=Literal["int", "str"]) + one_of_schemas: Set[str] = { "int", "str" } model_config = ConfigDict( validate_assignment=True, 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 27ab1abf97f..f180178737d 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 @@ -20,7 +20,7 @@ from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] @@ -34,7 +34,7 @@ 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] = Field(default=Literal["EnumString1", "EnumString2"]) + one_of_schemas: Set[str] = { "EnumString1", "EnumString2" } model_config = ConfigDict( validate_assignment=True, 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 4e9f0223199..06798245b8f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -20,7 +20,7 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -34,7 +34,7 @@ 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] = Field(default=Literal["BasquePig", "DanishPig"]) + one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } model_config = ConfigDict( validate_assignment=True, diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py index 9494a1a1167..cc1e1fc5a60 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -21,7 +21,7 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning from pydantic import StrictStr, Field -from typing import Union, List, Optional, Dict +from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] @@ -37,7 +37,7 @@ class TaskActivity(BaseModel): # data type: Bathing oneof_schema_3_validator: Optional[Bathing] = None actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: List[str] = Field(default=Literal["Bathing", "Feeding", "PoopCleaning"]) + one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } model_config = ConfigDict( validate_assignment=True,