team-3/src/c3nav/mapdata/schemas/responses.py

60 lines
1.8 KiB
Python
Raw Normal View History

2024-12-03 15:05:53 +01:00
from typing import Annotated, Union, Optional
from pydantic import Field as APIField
from pydantic import PositiveInt
2023-12-24 16:04:33 +01:00
from c3nav.api.schema import BaseSchema, GeometrySchema
2024-12-03 15:05:53 +01:00
from c3nav.mapdata.grid import GridSchema
from c3nav.mapdata.schemas.model_base import AnyLocationID, BoundsSchema
2024-12-03 15:05:53 +01:00
class MapSettingsSchema(BaseSchema):
"""
various c3nav instance settings
"""
initial_bounds: Optional[BoundsSchema] = APIField(
title="initial boundaries",
description="(left, bottom) to (top, right)",
)
initial_level: Optional[PositiveInt] = APIField(
title="initial level id",
description="the level id that is intially shown when opening the map",
)
grid: Optional[GridSchema] = APIField(
title="grid config",
description="grid configuration, if available",
)
tile_server: Optional[str] = APIField(
title="tile server base URL",
description="tile server base URL to use, if configured",
)
class WithBoundsSchema(BaseSchema):
"""
Describing a bounding box
"""
bounds: BoundsSchema = APIField(
2023-12-04 13:55:24 +01:00
title="boundaries",
description="(left, bottom) to (top, right)",
)
class LocationGeometry(BaseSchema):
id: AnyLocationID = APIField(
description="ID of the location that the geometry is being queried for",
)
level: Union[
Annotated[PositiveInt, APIField(title="level ID")],
Annotated[None, APIField(title="null", description="geometry is not on any level")], # todo: possible?
] = APIField(
description="ID of the level the geometry is on",
)
geometry: Union[
GeometrySchema,
Annotated[None, APIField(title="null", description="no geometry available")]
] = APIField(
description="geometry, if available"
)