Add Country schema

This commit is contained in:
Backend IM Bot 2025-03-25 19:50:27 +01:00
parent 469f3115b9
commit 8b1b92bcaa

26
schemas/country.py Normal file
View File

@ -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