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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user