From c25b12c1c030aa8ef78206c8fe64d3f3c57a301f Mon Sep 17 00:00:00 2001 From: Gwendolyn Date: Mon, 16 Dec 2024 15:58:18 +0100 Subject: [PATCH] slimmer and more correct routing item schema --- src/c3nav/routing/api/routing.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/c3nav/routing/api/routing.py b/src/c3nav/routing/api/routing.py index 2f434081..91075ed4 100644 --- a/src/c3nav/routing/api/routing.py +++ b/src/c3nav/routing/api/routing.py @@ -127,6 +127,18 @@ class ShortWayTypeSchema(DjangoModelSchema): pass +class ShortSpaceSchema(DjangoModelSchema): + pass + +class RouteLevelSchema(DjangoModelSchema): + on_top_of: Union[ + Annotated[PositiveInt, APIField(title="level ID", description="level this level is on top of", example=1)], + Annotated[None, APIField(title="null", description="this is a main level, not on top of any other")] + ] = APIField( + title="on top of level ID", + description="if set, this is not a main level, but it's on top of this other level" + ) + class RouteItemSchema(BaseSchema): id: PositiveInt coordinates: Coordinates3D @@ -136,14 +148,14 @@ class RouteItemSchema(BaseSchema): ] = APIField(None, title="waytype") space: Union[ Annotated[ - SlimSpaceLocationSchema, + ShortSpaceSchema, APIField(title="space", descripiton="new space that is being entered") ], Annotated[None, APIField(title="null", description="staying in the same space")], ] = APIField(None, description="new space being entered") level: Union[ Annotated[ - SlimLevelLocationSchema, + RouteLevelSchema, APIField(title="level", descripiton="new level that is being entered") ], Annotated[None, APIField(title="null", description="staying in the same level")], @@ -151,7 +163,7 @@ class RouteItemSchema(BaseSchema): descriptions: list[tuple[ Annotated[NonEmptyStr, APIField( title="icon name", - description="any material design icon name" + description="any material design icon name or svg icon file name" )], Annotated[NonEmptyStr, APIField( title="instruction", @@ -159,7 +171,6 @@ class RouteItemSchema(BaseSchema): )] ]] - class RouteSchema(BaseSchema): origin: SlimLocationSchema # todo: is this fine? works? no issues? destination: SlimLocationSchema # todo: is this fine? works? no issues?