-
-
Notifications
You must be signed in to change notification settings - Fork 412
Open
Description
Right now when we use some parameters during model generation (for example --extra-fields=forbid) we will get this:
class ModelA(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
fieldA: Annotated[
fieldA, Field(description="The filed name of the field")
]
class ModelB(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
fieldB: Annotated[
int,
Field(description="The field B number", ge=1, le=63),
]
class ModelC(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
page: Annotated[
str,And this pattern follow for as many openapi models we have.
Could we maybe do something like this? Lets keep the code DRY.
class ProjectBaseModel(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
class ModelA(ProjectBaseModel):
fieldA: Annotated[
fieldA, Field(description="The filed name of the field")
]
class ModelB(ProjectBaseModel):
fieldB: Annotated[
int,
Field(description="The field B number", ge=1, le=63),
]
class ModelC(ProjectBaseModel):
page: Annotated[
str,Metadata
Metadata
Assignees
Labels
No labels