forked from loafle/openapi-generator-original
Remove pydantic warnings when using model_dump by fixing one_of_schemas type (#17941)
This commit is contained in:
parent
7f1e79f7d2
commit
82fcf28a2b
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user