From 50b055635c6cfff907409b45f98eb3e8e878e3b6 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 12:59:07 +0000 Subject: [PATCH] Add Country schema --- schemas/country.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 schemas/country.py diff --git a/schemas/country.py b/schemas/country.py new file mode 100644 index 0000000..bb70a9c --- /dev/null +++ b/schemas/country.py @@ -0,0 +1,43 @@ +from pydantic import BaseModel, Field +from typing import Optional + +class CountryBase(BaseModel): + name: str = Field(..., description="Country name") + code: str = Field(..., description="Country code", min_length=2, max_length=3) + capital: Optional[str] = Field(None, description="Capital city") + region: Optional[str] = Field(None, description="Geographic region") + subregion: Optional[str] = Field(None, description="Geographic subregion") + population: Optional[str] = Field(None, description="Country population") + flag: Optional[str] = Field(None, description="Country flag URL") + +class CountryCreate(CountryBase): + class Config: + schema_extra = { + "example": { + "name": "United States", + "code": "USA", + "capital": "Washington, D.C.", + "region": "Americas", + "subregion": "North America", + "population": "331,002,651", + "flag": "https://example.com/usa-flag.png" + } + } + +class Country(CountryBase): + id: int = Field(..., description="Unique identifier for the country") + + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": 1, + "name": "United States", + "code": "USA", + "capital": "Washington, D.C.", + "region": "Americas", + "subregion": "North America", + "population": "331,002,651", + "flag": "https://example.com/usa-flag.png" + } + } \ No newline at end of file