34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
MAX_PLACE_SEARCH_RESULTS = 10
|
|
|
|
|
|
class PlaceSearchRequest(BaseModel):
|
|
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
|
|
|
|
keyword: str = Field(..., min_length=1, max_length=120)
|
|
|
|
|
|
class ReverseGeocodingRequest(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
longitude: float = Field(ge=-180, le=180, allow_inf_nan=False)
|
|
latitude: float = Field(ge=-90, le=90, allow_inf_nan=False)
|
|
|
|
|
|
class PlaceSearchItem(BaseModel):
|
|
id: str = Field(..., min_length=1)
|
|
name: str = Field(..., min_length=1)
|
|
address: str
|
|
longitude: float = Field(..., ge=-180, le=180, allow_inf_nan=False)
|
|
latitude: float = Field(..., ge=-90, le=90, allow_inf_nan=False)
|
|
category: str | None = None
|
|
district: str = Field(min_length=1)
|
|
|
|
|
|
class PlaceSearchResponse(BaseModel):
|
|
items: list[PlaceSearchItem] = Field(..., max_length=MAX_PLACE_SEARCH_RESULTS)
|
|
total: int = Field(..., ge=0, le=MAX_PLACE_SEARCH_RESULTS)
|
|
truncated: bool = False
|
|
region: str = Field(min_length=1)
|