Add Country schema

This commit is contained in:
Backend IM Bot 2025-03-26 22:28:59 +00:00
parent 1b1c6d5b93
commit 98bdf94eb8

28
schemas/country.py Normal file
View File

@ -0,0 +1,28 @@
from pydantic import BaseModel, Field
from typing import Optional
class CountryBase(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
code: str = Field(..., min_length=2, max_length=2)
class CountryCreate(CountryBase):
class Config:
schema_extra = {
"example": {
"name": "United States",
"code": "US"
}
}
class Country(CountryBase):
id: int
class Config:
orm_mode = True
schema_extra = {
"example": {
"id": 1,
"name": "United States",
"code": "US"
}
}