mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
[python] update model_config from dict to ConfigDict (#17900)
* [python] rewrite dict as ConfigDict * [python] update sample * [python] undo unwanted changes * [python] update sample
This commit is contained in:
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -31,11 +31,11 @@ class Bird(BaseModel):
|
||||
color: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["size", "color"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -31,11 +31,11 @@ class Category(BaseModel):
|
||||
name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "name"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -19,7 +19,7 @@ import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import Field, StrictStr
|
||||
from pydantic import ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.query import Query
|
||||
from typing import Optional, Set
|
||||
@@ -34,11 +34,11 @@ class DataQuery(Query):
|
||||
var_date: Optional[datetime] = Field(default=None, description="A date", alias="date")
|
||||
__properties: ClassVar[List[str]] = ["id", "outcomes", "suffix", "text", "date"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.string_enum_ref import StringEnumRef
|
||||
from typing import Optional, Set
|
||||
@@ -49,11 +49,11 @@ class DefaultValue(BaseModel):
|
||||
raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')")
|
||||
return value
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictFloat, StrictInt
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing_extensions import Annotated
|
||||
from typing import Optional, Set
|
||||
@@ -33,11 +33,11 @@ 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: ClassVar[List[str]] = ["number", "float", "double"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from openapi_client.models.category import Category
|
||||
from openapi_client.models.tag import Tag
|
||||
@@ -47,11 +47,11 @@ class Pet(BaseModel):
|
||||
raise ValueError("must be one of enum values ('available', 'pending', 'sold')")
|
||||
return value
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -42,11 +42,11 @@ class Query(BaseModel):
|
||||
raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')")
|
||||
return value
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -31,11 +31,11 @@ class Tag(BaseModel):
|
||||
name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "name"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -33,11 +33,11 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
|
||||
name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["size", "color", "id", "name"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
@@ -18,7 +18,7 @@ import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
@@ -30,11 +30,11 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
|
||||
values: Optional[List[StrictStr]] = None
|
||||
__properties: ClassVar[List[str]] = ["values"]
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user