Chittrarasu/Population_FastAPI
0
1from pydantic import BaseModel, Field2from typing import List, Union3 4class ContinentBase(BaseModel):5 continent: str = Field(..., title="Continent Name", example="Asia")6 7class ContinentStats(BaseModel):8 Total_Countries: int = Field(..., title="Total Number of Countries", example=48)9 Total_Population: int = Field(..., title="Total Population", example=4600000000)10 Average_Population: float = Field(..., title="Average Population Per Country", example=96000000)11 Total_Area: int = Field(..., title="Total Land Area (sq km)", example=44679000)12 max_population: int = Field(..., title="Highest Country Population", example=1400000000)13 min_population: int = Field(..., title="Lowest Country Population", example=100000)14 Country_Max_Population: str = Field(..., title="Country with Highest Population", example="China")15 Country_Min_Population: str = Field(..., title="Country with Lowest Population", example="Maldives")16 Population_Density: float = Field(..., title="Population Density (people/sq km)", example=103)17 18class ContinentResponse(BaseModel):19 continent: str = Field(..., title="Continent Name", example="Asia")20 statistics: ContinentStats21 22class ContinentsListResponse(BaseModel):23 continents: List[str] = Field(..., title="List of Continents", example=["Asia", "Europe", "Africa"])24 25class StatResponse(BaseModel):26 stat: str = Field(..., title="Statistic Name", example="Total Population")27 value: Union[str, int, float] = Field(..., title="Statistic Value", example=4600000000)28 29 