Skip to content

Commit

Permalink
Documented parameters for actions & static
Browse files Browse the repository at this point in the history
Path parameters were previously missing from OpenAPI YAML.
  • Loading branch information
rwb27 committed Jul 19, 2021
1 parent 5f9d284 commit 38fb5ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/labthings/default_views/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ def get(self):
}


TASK_ID_PARAMETER = {
"name": "task_id",
"in": "path",
"description": "The unique ID of the action",
"required": True,
"schema": {"type": "string"},
"example": "eeae7ae9-0c0d-45a4-9ef2-7b84bb67a1d1",
}


class ActionObjectView(View):
"""Manage a particular action.
Expand All @@ -37,6 +47,8 @@ class ActionObjectView(View):
"""

parameters = [TASK_ID_PARAMETER]

def get(self, task_id):
"""Show the status of an Action
Expand Down
18 changes: 17 additions & 1 deletion src/labthings/views/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ def _get(_, path=""):
}

# Generate a basic property class
generated_class = type(name, (View, object), {"get": _get})
generated_class = type(
name,
(View, object),
{
"get": _get,
"parameters": [
{
"name": "path",
"in": "path",
"description": "Path to the static file",
"required": True,
"schema": {"type": "string"},
"example": "style.css",
}
],
},
)

return generated_class

0 comments on commit 38fb5ca

Please sign in to comment.