54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
"""Bus stop schemas."""
|
|
from pydantic import BaseModel, field_serializer
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
from app.models.bus_stop import StopType
|
|
|
|
|
|
class BusStopBase(BaseModel):
|
|
"""Base bus stop schema."""
|
|
name: str
|
|
latitude: float
|
|
longitude: float
|
|
city: str
|
|
address: Optional[str] = None
|
|
stop_type: StopType = StopType.REGULAR
|
|
has_shelter: bool = False
|
|
has_seating: bool = False
|
|
is_accessible: bool = False
|
|
stop_order: Optional[int] = None
|
|
|
|
|
|
class BusStopCreate(BusStopBase):
|
|
"""Schema for creating a bus stop."""
|
|
pass
|
|
|
|
|
|
class BusStopUpdate(BaseModel):
|
|
"""Schema for updating a bus stop."""
|
|
name: Optional[str] = None
|
|
latitude: Optional[float] = None
|
|
longitude: Optional[float] = None
|
|
city: Optional[str] = None
|
|
address: Optional[str] = None
|
|
stop_type: Optional[StopType] = None
|
|
has_shelter: Optional[bool] = None
|
|
has_seating: Optional[bool] = None
|
|
is_accessible: Optional[bool] = None
|
|
|
|
|
|
class BusStopResponse(BusStopBase):
|
|
"""Schema for bus stop response."""
|
|
id: UUID
|
|
created_at: Optional[datetime] = None
|
|
updated_at: Optional[datetime] = None
|
|
|
|
@field_serializer('id')
|
|
def serialize_id(self, value: UUID) -> str:
|
|
return str(value)
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|