Add Country schema

This commit is contained in:
Backend IM Bot 2025-03-26 16:48:56 +00:00
parent e690b9350b
commit 41f084ca3e

40
schemas/country.py Normal file
View File

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