26 lines
852 B
Python
26 lines
852 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
import uuid
|
|
|
|
class CityBase(BaseModel):
|
|
name: str = Field(..., description="Name of the city")
|
|
state: str = Field(..., description="State the city belongs to")
|
|
country: str = Field("Nigeria", description="Country the city belongs to")
|
|
population: int = Field(..., description="Population of the city")
|
|
|
|
class CityCreate(CityBase):
|
|
pass
|
|
|
|
class CityUpdate(CityBase):
|
|
name: Optional[str] = Field(None, description="Name of the city")
|
|
state: Optional[str] = Field(None, description="State the city belongs to")
|
|
population: Optional[int] = Field(None, description="Population of the city")
|
|
|
|
class CitySchema(CityBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True |