make editor geometries schema a bit more generic
This commit is contained in:
parent
12220823c3
commit
02e3fd60e6
2 changed files with 9 additions and 28 deletions
|
@ -53,7 +53,7 @@ def geometrystyles(request):
|
||||||
|
|
||||||
|
|
||||||
@editor_api_router.get('/geometries/space/{space_id}/', summary="get the geometries to display for a space",
|
@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},
|
**auth_permission_responses},
|
||||||
openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]})
|
openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]})
|
||||||
@newapi_etag_with_update_cache_key(etag_func=editor_etag_func)
|
@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",
|
@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},
|
**auth_permission_responses},
|
||||||
openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]})
|
openapi_extra={"security": [{"APITokenAuth": ["editor_access"]}]})
|
||||||
@newapi_etag_with_update_cache_key(etag_func=editor_etag_func)
|
@newapi_etag_with_update_cache_key(etag_func=editor_etag_func)
|
||||||
|
|
|
@ -40,9 +40,11 @@ EditorGeometriesCacheReferenceElem = Annotated[
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class BaseEditorGeometriesPropertiesSchema(Schema):
|
class EditorGeometriesPropertiesSchema(Schema):
|
||||||
id: EditorID
|
id: EditorID
|
||||||
type: NonEmptyStr
|
type: NonEmptyStr
|
||||||
|
space: Optional[EditorID] = None
|
||||||
|
level: Optional[EditorID] = None
|
||||||
bounds: bool = False
|
bounds: bool = False
|
||||||
color: Optional[str] = None
|
color: Optional[str] = None
|
||||||
opacity: Optional[float] = None # todo: range
|
opacity: Optional[float] = None # todo: range
|
||||||
|
@ -55,46 +57,25 @@ class EditorGeometriesGraphEdgePropertiesSchema(Schema):
|
||||||
to_node: EditorID
|
to_node: EditorID
|
||||||
|
|
||||||
|
|
||||||
class EditorSpaceGeometriesPropertiesSchema(BaseEditorGeometriesPropertiesSchema):
|
|
||||||
space: EditorID
|
|
||||||
|
|
||||||
|
|
||||||
class EditorLevelGeometriesPropertiesSchema(BaseEditorGeometriesPropertiesSchema):
|
|
||||||
level: EditorID
|
|
||||||
|
|
||||||
|
|
||||||
class EditorGeometriesGraphEdgeElemSchema(Schema):
|
class EditorGeometriesGraphEdgeElemSchema(Schema):
|
||||||
type: Literal["Feature"]
|
type: Literal["Feature"]
|
||||||
properties: EditorGeometriesGraphEdgePropertiesSchema
|
properties: EditorGeometriesGraphEdgePropertiesSchema
|
||||||
geometry: LineSchema
|
geometry: LineSchema
|
||||||
|
|
||||||
|
|
||||||
class BaseEditorGeometriesGeometryElemSchema(Schema):
|
class EditorGeometriesGeometryElemSchema(Schema):
|
||||||
type: Literal["Feature"]
|
type: Literal["Feature"]
|
||||||
geometry: AnyGeometrySchema = APIField(description="geometry, potentially modified for displaying")
|
geometry: AnyGeometrySchema = APIField(description="geometry, potentially modified for displaying")
|
||||||
original_geometry: Optional[GeometrySchema] = APIField(
|
original_geometry: Optional[GeometrySchema] = APIField(
|
||||||
default=None,
|
default=None,
|
||||||
description="original unchanged geometry, not modified, original(??)", # todo: more precise
|
description="original unchanged geometry, not modified, original(??)", # todo: more precise
|
||||||
)
|
)
|
||||||
|
properties: EditorGeometriesPropertiesSchema
|
||||||
|
|
||||||
|
|
||||||
class EditorSpaceGeometriesGeometryElemSchema(BaseEditorGeometriesGeometryElemSchema):
|
EditorGeometriesElemSchema = Union[
|
||||||
properties: EditorSpaceGeometriesPropertiesSchema
|
|
||||||
|
|
||||||
|
|
||||||
class EditorLevelGeometriesGeometryElemSchema(BaseEditorGeometriesGeometryElemSchema):
|
|
||||||
properties: EditorLevelGeometriesPropertiesSchema
|
|
||||||
|
|
||||||
|
|
||||||
EditorSpaceGeometriesElemSchema = Union[
|
|
||||||
EditorGeometriesUpdateCacheKeyElem,
|
EditorGeometriesUpdateCacheKeyElem,
|
||||||
Annotated[EditorSpaceGeometriesGeometryElemSchema, APIField(title="a geometry object")],
|
Annotated[EditorGeometriesGeometryElemSchema, APIField(title="a geometry object")],
|
||||||
Annotated[EditorGeometriesGraphEdgeElemSchema, APIField(title="a graph edge")],
|
|
||||||
EditorGeometriesCacheReferenceElem,
|
|
||||||
]
|
|
||||||
EditorLevelGeometriesElemSchema = Union[
|
|
||||||
EditorGeometriesUpdateCacheKeyElem,
|
|
||||||
Annotated[EditorLevelGeometriesGeometryElemSchema, APIField(title="a geometry object")],
|
|
||||||
Annotated[EditorGeometriesGraphEdgeElemSchema, APIField(title="a graph edge")],
|
Annotated[EditorGeometriesGraphEdgeElemSchema, APIField(title="a graph edge")],
|
||||||
EditorGeometriesCacheReferenceElem,
|
EditorGeometriesCacheReferenceElem,
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue