serialize waytype correct
This commit is contained in:
parent
ca4008c13c
commit
d151bc7888
2 changed files with 9 additions and 3 deletions
|
@ -18,7 +18,7 @@ from c3nav.api.utils import NonEmptyStr
|
|||
from c3nav.mapdata.api.base import api_stats_clean_location_value
|
||||
from c3nav.mapdata.models.access import AccessPermission
|
||||
from c3nav.mapdata.models.locations import Position
|
||||
from c3nav.mapdata.schemas.model_base import AnyLocationID, Coordinates3D
|
||||
from c3nav.mapdata.schemas.model_base import AnyLocationID, Coordinates3D, TitledSchema, DjangoModelSchema
|
||||
from c3nav.mapdata.schemas.models import SlimLocationSchema, SpaceSchema, LevelSchema, SlimSpaceLocationSchema, \
|
||||
SlimLevelLocationSchema
|
||||
from c3nav.mapdata.utils.cache.stats import increment_cache_key
|
||||
|
@ -123,11 +123,15 @@ class RouteParametersSchema(BaseSchema):
|
|||
)
|
||||
|
||||
|
||||
class ShortWayTypeSchema(DjangoModelSchema):
|
||||
pass
|
||||
|
||||
|
||||
class RouteItemSchema(BaseSchema):
|
||||
id: PositiveInt
|
||||
coordinates: Coordinates3D
|
||||
waytype: Union[
|
||||
Annotated[dict, APIField(title="waytype", descripiton="waytype used for this segment")],
|
||||
Annotated[ShortWayTypeSchema, APIField(title="waytype", descripiton="waytype used for this segment")],
|
||||
Annotated[None, APIField(title="null", description="no waytype (normal walking)")],
|
||||
] = APIField(None, title="waytype")
|
||||
space: Union[
|
||||
|
|
|
@ -6,6 +6,8 @@ import numpy as np
|
|||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from c3nav.routing.api.routing import ShortWayTypeSchema
|
||||
|
||||
|
||||
def describe_location(location, locations):
|
||||
if location.can_describe:
|
||||
|
@ -240,7 +242,7 @@ class RouteItem:
|
|||
result = OrderedDict((
|
||||
('id', self.node.pk),
|
||||
('coordinates', (self.node.x, self.node.y, self.node.altitude)),
|
||||
('waytype', (self.route.router.waytypes[self.edge.waytype].serialize(detailed=False)
|
||||
('waytype', (ShortWayTypeSchema.model_validate(self.route.router.waytypes[self.edge.waytype]).model_dump()
|
||||
if self.edge and self.edge.waytype else None)),
|
||||
))
|
||||
if self.waytype:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue