Add Country schema
This commit is contained in:
parent
6cd6a623ac
commit
845aab24cd
@ -2,29 +2,25 @@ from pydantic import BaseModel, Field
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
class CountryBase(BaseModel):
|
class CountryBase(BaseModel):
|
||||||
name: str = Field(..., min_length=1, description="Country name")
|
name: str = Field(..., description="Country name")
|
||||||
code: str = Field(..., min_length=2, max_length=3, description="Country code")
|
code: str = Field(..., description="Country code", min_length=2, max_length=3)
|
||||||
flag: Optional[str] = Field(None, description="Country flag URL")
|
|
||||||
capital: Optional[str] = Field(None, description="Capital city")
|
capital: Optional[str] = Field(None, description="Capital city")
|
||||||
region: Optional[str] = Field(None, description="Geographic region")
|
region: Optional[str] = Field(None, description="Geographic region")
|
||||||
subregion: Optional[str] = Field(None, description="Geographic subregion")
|
subregion: Optional[str] = Field(None, description="Geographic subregion")
|
||||||
population: Optional[str] = Field(None, description="Population count")
|
population: Optional[str] = Field(None, description="Country population")
|
||||||
languages: Optional[str] = Field(None, description="Official languages")
|
flag: Optional[str] = Field(None, description="Country flag URL")
|
||||||
currencies: Optional[str] = Field(None, description="Official currencies")
|
|
||||||
|
|
||||||
class CountryCreate(CountryBase):
|
class CountryCreate(CountryBase):
|
||||||
class Config:
|
class Config:
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
"example": {
|
"example": {
|
||||||
"name": "United States",
|
"name": "United States",
|
||||||
"code": "USA",
|
"code": "US",
|
||||||
"flag": "https://example.com/us-flag.png",
|
|
||||||
"capital": "Washington, D.C.",
|
"capital": "Washington, D.C.",
|
||||||
"region": "Americas",
|
"region": "Americas",
|
||||||
"subregion": "North America",
|
"subregion": "North America",
|
||||||
"population": "331,002,651",
|
"population": "331,002,651",
|
||||||
"languages": "English",
|
"flag": "https://example.com/us-flag.png"
|
||||||
"currencies": "USD"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,13 +33,11 @@ class Country(CountryBase):
|
|||||||
"example": {
|
"example": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "United States",
|
"name": "United States",
|
||||||
"code": "USA",
|
"code": "US",
|
||||||
"flag": "https://example.com/us-flag.png",
|
|
||||||
"capital": "Washington, D.C.",
|
"capital": "Washington, D.C.",
|
||||||
"region": "Americas",
|
"region": "Americas",
|
||||||
"subregion": "North America",
|
"subregion": "North America",
|
||||||
"population": "331,002,651",
|
"population": "331,002,651",
|
||||||
"languages": "English",
|
"flag": "https://example.com/us-flag.png"
|
||||||
"currencies": "USD"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user