Support uriVariables in thing description
This commit is contained in:
parent
64f89c5355
commit
234ebc1cbb
1 changed files with 15 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ from openflexure_microscope.common.labthings_core.utilities import get_docstring
|
|||
|
||||
from ...resource import Resource
|
||||
from ...find import current_labthing
|
||||
from ...spec import rule_to_path
|
||||
from ...spec import rule_to_path, rule_to_params
|
||||
|
||||
import os
|
||||
|
||||
|
|
@ -57,6 +57,20 @@ class W3CThingDescriptionResource(Resource):
|
|||
{"href": f"{base_url}{url}"} for url in prop_urls
|
||||
]
|
||||
|
||||
props[key]["uriVariables"] = {}
|
||||
for prop_rule in prop_rules:
|
||||
params = rule_to_params(prop_rule)
|
||||
params_dict = {}
|
||||
for param in params:
|
||||
params_dict.update({
|
||||
param.get("name"): {
|
||||
"type": param.get("type")
|
||||
}
|
||||
})
|
||||
props[key]["uriVariables"].update(params_dict)
|
||||
if not props[key]["uriVariables"]:
|
||||
del props[key]["uriVariables"]
|
||||
|
||||
actions = {}
|
||||
for key, action in current_labthing().actions.items():
|
||||
action_rules = current_app.url_map._rules_by_endpoint.get(action.endpoint)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue