Add Country schema
This commit is contained in:
parent
b06c0a8751
commit
482c62a86d
37
schemas/country.py
Normal file
37
schemas/country.py
Normal file
@ -0,0 +1,37 @@
|
||||
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)
|
||||
currency: Optional[str] = Field(None, max_length=50)
|
||||
capital: Optional[str] = Field(None, max_length=100)
|
||||
region: Optional[str] = Field(None, max_length=100)
|
||||
|
||||
class CountryCreate(CountryBase):
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "United States",
|
||||
"code": "US",
|
||||
"currency": "USD",
|
||||
"capital": "Washington, D.C.",
|
||||
"region": "North America"
|
||||
}
|
||||
}
|
||||
|
||||
class Country(CountryBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"id": 1,
|
||||
"name": "United States",
|
||||
"code": "US",
|
||||
"currency": "USD",
|
||||
"capital": "Washington, D.C.",
|
||||
"region": "North America"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user