From 41f084ca3e320ad10dddbd5e30d8ae315a2ace46 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 16:48:56 +0000 Subject: [PATCH] Add Country schema --- schemas/country.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 schemas/country.py 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