From 8b1b92bcaabe761f79a21e89184eeee820e39439 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 19:50:27 +0100 Subject: [PATCH] Add Country schema --- schemas/country.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 schemas/country.py 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