From 48fa1842a9b6878ffafe9ac6d38a6168c78a16c5 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 13 Jul 2021 22:53:35 +0100 Subject: [PATCH] Fixed stage schemas If missing=None, we need to specify allow_None=False in order to generate valid OpenAPI. This may also be fixed by an upstream change in LabThings. Also, OneOf was being used incorrectly in StageTypeProperty. --- .../api/v2/views/actions/stage.py | 14 +++++++++----- openflexure_microscope/api/v2/views/stage.py | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openflexure_microscope/api/v2/views/actions/stage.py b/openflexure_microscope/api/v2/views/actions/stage.py index 206d9623..dd87e7e0 100644 --- a/openflexure_microscope/api/v2/views/actions/stage.py +++ b/openflexure_microscope/api/v2/views/actions/stage.py @@ -9,16 +9,19 @@ class MoveStageAPI(ActionView): "absolute": fields.Boolean( missing=False, example=False, description="Move to an absolute position" ), - "x": fields.Int(missing=None, example=100), - "y": fields.Int(missing=None, example=100), - "z": fields.Int(missing=None, example=20), + "x": fields.Int(missing=None, example=100, allow_none=False), + "y": fields.Int(missing=None, example=100, allow_none=False), + "z": fields.Int(missing=None, example=20, allow_none=False), } def post(self, args): """ Move the microscope stage in x, y, z - Any axes that are not specifed will not move. + This action moves the stage. Any axes that are not specifed will not move. + If `absolute=True` is specified, the stage will move to the absolute + coordinates given. If not (the default), a relative move is made, i.e. + `x=0, y=0, z=0` corresponds to no motion. """ microscope = find_component("org.openflexure.microscope") @@ -50,7 +53,8 @@ class ZeroStageAPI(ActionView): def post(self): """ Zero the stage coordinates. - Does not move the stage, but rather makes the current position read as [0, 0, 0] + + This action does not move the stage, but rather makes the current position read as [0, 0, 0] """ microscope = find_component("org.openflexure.microscope") diff --git a/openflexure_microscope/api/v2/views/stage.py b/openflexure_microscope/api/v2/views/stage.py index e65138eb..21d19e94 100644 --- a/openflexure_microscope/api/v2/views/stage.py +++ b/openflexure_microscope/api/v2/views/stage.py @@ -1,5 +1,6 @@ from labthings import fields, find_component from labthings.views import PropertyView +from marshmallow import validate class StageTypeProperty(PropertyView): @@ -8,8 +9,9 @@ class StageTypeProperty(PropertyView): schema = fields.String( missing=None, example="SangaStage", - OneOf=["SangaStage", "SangaDeltaStage"], + validate=validate.OneOf(["SangaStage", "SangaDeltaStage"]), description="The translation stage geometry", + allow_none=False, ) def get(self):