Add State schema
This commit is contained in:
parent
261711731b
commit
02c2cfd247
28
schemas/state.py
Normal file
28
schemas/state.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
class StateBase(BaseModel):
|
||||||
|
name: str = Field(..., min_length=1, max_length=100)
|
||||||
|
country_code: str = Field(..., min_length=2, max_length=2)
|
||||||
|
|
||||||
|
class StateCreate(StateBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "California",
|
||||||
|
"country_code": "US"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class State(StateBase):
|
||||||
|
id: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"id": 1,
|
||||||
|
"name": "California",
|
||||||
|
"country_code": "US"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user