diff --git a/schemas/country.py b/schemas/country.py new file mode 100644 index 0000000..d75854e --- /dev/null +++ b/schemas/country.py @@ -0,0 +1,26 @@ +from pydantic import BaseModel, Field + +class CountryBase(BaseModel): + name: str = Field(..., index=True, unique=True, description="Country name") + code: str = Field(..., min_length=3, max_length=3, description="Country code (3 characters)") + population: int = Field(..., gt=0, description="Country population") + area: int = Field(..., gt=0, description="Country area") + + class Config: + schema_extra = { + "example": { + "name": "United States", + "code": "USA", + "population": 329500000, + "area": 9833520 + } + } + +class CountryCreate(CountryBase): + pass + +class CountryResponse(CountryBase): + id: int + + class Config: + orm_mode = True \ No newline at end of file