Add Country schema
This commit is contained in:
parent
a47c5b5e0b
commit
7b32f25c8e
@ -2,36 +2,27 @@ from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
class CountryBase(BaseModel):
|
||||
name: str = Field(..., index=True, min_length=1, description="Country name")
|
||||
iso2: str = Field(..., min_length=2, max_length=2, description="ISO 3166-1 alpha-2 code")
|
||||
iso3: str = Field(..., min_length=3, max_length=3, description="ISO 3166-1 alpha-3 code")
|
||||
capital: str = Field(..., min_length=1, description="Capital city")
|
||||
region: str = Field(..., min_length=1, description="Geographic region")
|
||||
subregion: str = Field(..., min_length=1, description="Geographic subregion")
|
||||
population: str = Field(..., min_length=1, description="Population count")
|
||||
latitude: str = Field(..., min_length=1, description="Latitude coordinates")
|
||||
longitude: str = Field(..., min_length=1, description="Longitude coordinates")
|
||||
flag: str = Field(..., min_length=1, description="Flag image URL")
|
||||
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",
|
||||
"iso2": "US",
|
||||
"iso3": "USA",
|
||||
"capital": "Washington, D.C.",
|
||||
"region": "Americas",
|
||||
"subregion": "North America",
|
||||
"population": "331002651",
|
||||
"latitude": "37.09024",
|
||||
"longitude": "-95.712891",
|
||||
"flag": "https://example.com/us-flag.png"
|
||||
"code": "US"
|
||||
}
|
||||
}
|
||||
|
||||
class Country(CountryBase):
|
||||
id: int = Field(..., description="Unique identifier")
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
orm_mode = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"id": 1,
|
||||
"name": "United States",
|
||||
"code": "US"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user