Add City schema
This commit is contained in:
parent
d6c4cb8aa4
commit
050dab3426
34
schemas/city.py
Normal file
34
schemas/city.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
class CityBase(BaseModel):
|
||||||
|
name: str = Field(..., min_length=1, max_length=100, description="City name")
|
||||||
|
endpoint: str = Field(..., min_length=1, max_length=200, description="City endpoint")
|
||||||
|
description: Optional[str] = Field(None, description="City description")
|
||||||
|
is_active: bool = Field(default=True, description="City active status")
|
||||||
|
|
||||||
|
class CityCreate(CityBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "New York",
|
||||||
|
"endpoint": "/new-york",
|
||||||
|
"description": "The Big Apple",
|
||||||
|
"is_active": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class City(CityBase):
|
||||||
|
id: int = Field(..., description="City ID")
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"id": 1,
|
||||||
|
"name": "New York",
|
||||||
|
"endpoint": "/new-york",
|
||||||
|
"description": "The Big Apple",
|
||||||
|
"is_active": True
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user