25 lines
676 B
Python
25 lines
676 B
Python
# Base Schema
|
|
class StateBase(BaseModel):
|
|
name: str = Field(..., unique=True, index=True, description="Name of the state")
|
|
abbreviation: str = Field(..., unique=True, index=True, description="Abbreviation of the state")
|
|
is_active: bool = Field(True, description="Whether the state is active or not")
|
|
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"name": "California",
|
|
"abbreviation": "CA",
|
|
"is_active": True
|
|
}
|
|
}
|
|
|
|
# Create Schema
|
|
class StateCreate(StateBase):
|
|
pass
|
|
|
|
# Response Schema
|
|
class StateResponse(StateBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True |