diff --git a/src/c3nav/editor/newapi/endpoints.py b/src/c3nav/editor/newapi/endpoints.py index abd87616..e6d8fee0 100644 --- a/src/c3nav/editor/newapi/endpoints.py +++ b/src/c3nav/editor/newapi/endpoints.py @@ -53,7 +53,7 @@ def geometrystyles(request): @editor_api_router.get('/geometries/space/{space_id}/', summary="get the geometries to display for a space", - response={200: list[EditorSpaceGeometriesElemSchema], **API404.dict(), + response={200: list[EditorGeometriesElemSchema], **API404.dict(), **auth_permission_responses}, openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]}) @newapi_etag_with_update_cache_key(etag_func=editor_etag_func) @@ -75,7 +75,7 @@ def space_geometries(request, space_id: EditorID, update_cache_key: UpdateCacheK @editor_api_router.get('/geometries/level/{level_id}/', summary="get the geometries to display for a level", - response={200: list[EditorLevelGeometriesElemSchema], **API404.dict(), + response={200: list[EditorGeometriesElemSchema], **API404.dict(), **auth_permission_responses}, openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]}) @newapi_etag_with_update_cache_key(etag_func=editor_etag_func) diff --git a/src/c3nav/editor/newapi/schemas.py b/src/c3nav/editor/newapi/schemas.py index 79ade9eb..ab279b7f 100644 --- a/src/c3nav/editor/newapi/schemas.py +++ b/src/c3nav/editor/newapi/schemas.py @@ -40,9 +40,11 @@ EditorGeometriesCacheReferenceElem = Annotated[ ] -class BaseEditorGeometriesPropertiesSchema(Schema): +class EditorGeometriesPropertiesSchema(Schema): id: EditorID type: NonEmptyStr + space: Optional[EditorID] = None + level: Optional[EditorID] = None bounds: bool = False color: Optional[str] = None opacity: Optional[float] = None # todo: range @@ -55,46 +57,25 @@ class EditorGeometriesGraphEdgePropertiesSchema(Schema): to_node: EditorID -class EditorSpaceGeometriesPropertiesSchema(BaseEditorGeometriesPropertiesSchema): - space: EditorID - - -class EditorLevelGeometriesPropertiesSchema(BaseEditorGeometriesPropertiesSchema): - level: EditorID - - class EditorGeometriesGraphEdgeElemSchema(Schema): type: Literal["Feature"] properties: EditorGeometriesGraphEdgePropertiesSchema geometry: LineSchema -class BaseEditorGeometriesGeometryElemSchema(Schema): +class EditorGeometriesGeometryElemSchema(Schema): type: Literal["Feature"] geometry: AnyGeometrySchema = APIField(description="geometry, potentially modified for displaying") original_geometry: Optional[GeometrySchema] = APIField( default=None, description="original unchanged geometry, not modified, original(??)", # todo: more precise ) + properties: EditorGeometriesPropertiesSchema -class EditorSpaceGeometriesGeometryElemSchema(BaseEditorGeometriesGeometryElemSchema): - properties: EditorSpaceGeometriesPropertiesSchema - - -class EditorLevelGeometriesGeometryElemSchema(BaseEditorGeometriesGeometryElemSchema): - properties: EditorLevelGeometriesPropertiesSchema - - -EditorSpaceGeometriesElemSchema = Union[ +EditorGeometriesElemSchema = Union[ EditorGeometriesUpdateCacheKeyElem, - Annotated[EditorSpaceGeometriesGeometryElemSchema, APIField(title="a geometry object")], - Annotated[EditorGeometriesGraphEdgeElemSchema, APIField(title="a graph edge")], - EditorGeometriesCacheReferenceElem, -] -EditorLevelGeometriesElemSchema = Union[ - EditorGeometriesUpdateCacheKeyElem, - Annotated[EditorLevelGeometriesGeometryElemSchema, APIField(title="a geometry object")], + Annotated[EditorGeometriesGeometryElemSchema, APIField(title="a geometry object")], Annotated[EditorGeometriesGraphEdgeElemSchema, APIField(title="a graph edge")], EditorGeometriesCacheReferenceElem, ]