from pydantic import BaseModel, Field class CountryPopulation(BaseModel): country: str population: int class ContinentPopulationResponse(BaseModel): continent: str = Field(..., description="Name of the continent") total_population: int = Field(..., description="Total population of the continent") total_area: int = Field(..., description="Total area of the continent") continent_population_density: float = Field(..., description="Population density of the continent") max_population: CountryPopulation = Field(..., description="Country with the maximum population") min_population: CountryPopulation = Field(..., description="Country with the minimum population") avg_population: int = Field(..., description="Average population of the continent") # Schema-level configuration model_config = { "json_schema_extra": { "examples": [ { "continent": "Asia", "total_population": 4641054775, "total_area": 44579000, "continent_population_density": 104.1, "max_population": {"country": "China", "population": 1411778724}, "min_population": {"country": "Maldives", "population": 521874}, "avg_population": 92821192 } ] } }