diff --git a/schemas/country.py b/schemas/country.py new file mode 100644 index 0000000..0889406 --- /dev/null +++ b/schemas/country.py @@ -0,0 +1,40 @@ +from pydantic import BaseModel, Field, constr +from typing import Optional + +class CountryBase(BaseModel): + name: str = Field(..., min_length=1, max_length=100, description="Country name") + code: constr(min_length=2, max_length=2) = Field(..., description="Two-letter country code") + capital: str = Field(..., min_length=1, description="Capital city") + region: str = Field(..., min_length=1, description="Geographic region") + currency: str = Field(..., min_length=1, description="Official currency") + language: str = Field(..., min_length=1, description="Official language") + +class CountryCreate(CountryBase): + class Config: + schema_extra = { + "example": { + "name": "France", + "code": "FR", + "capital": "Paris", + "region": "Europe", + "currency": "EUR", + "language": "French" + } + } + +class Country(CountryBase): + id: int + + class Config: + orm_mode = True + schema_extra = { + "example": { + "id": 1, + "name": "France", + "code": "FR", + "capital": "Paris", + "region": "Europe", + "currency": "EUR", + "language": "French" + } + } \ No newline at end of file