Add State schema
This commit is contained in:
parent
3f2897e729
commit
3c6e6e30a4
25
schemas/state.py
Normal file
25
schemas/state.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# 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
|
Loading…
x
Reference in New Issue
Block a user