Skip to content

Commit 65d3b0e

Browse files
author
Joel Collins
committed
Minor fixes
1 parent 0eb7930 commit 65d3b0e

File tree

1 file changed

+8
-5
lines changed
  • labthings/server/spec

1 file changed

+8
-5
lines changed

labthings/server/spec/td.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
def find_schema_for_view(view: View):
1515
"""Find the broadest available data schema for a Flask view
1616
17-
First looks for class-level, then GET, POST, and PUT methods depending on if the
18-
view is read/write only
17+
Looks for GET, POST, and PUT methods depending on if the view is read/write only
1918
2019
Args:
2120
view (View): View to search for schema
@@ -34,9 +33,11 @@ def find_schema_for_view(view: View):
3433
if hasattr(view, "post"):
3534
# Use POST schema
3635
prop_schema = get_spec(view.post).get("_params")
37-
elif hasattr(view, "put"):
36+
else:
3837
# Use PUT schema
3938
prop_schema = get_spec(view.put).get("_params")
39+
else:
40+
prop_schema = {}
4041

4142
return prop_schema
4243

@@ -195,11 +196,13 @@ def view_to_thing_action_forms(self, rules: list, view: View):
195196
return self.build_forms_for_view(rules, view, op=["invokeaction"])
196197

197198
def property(self, rules: list, view: View):
198-
key = snake_to_camel(view.endpoint)
199+
endpoint = getattr(view, "endpoint") or getattr(rules[0], "endpoint")
200+
key = snake_to_camel(endpoint)
199201
self.properties[key] = self.view_to_thing_property(rules, view)
200202

201203
def action(self, rules: list, view: View):
202-
key = snake_to_camel(view.endpoint)
204+
endpoint = getattr(view, "endpoint") or getattr(rules[0], "endpoint")
205+
key = snake_to_camel(endpoint)
203206
self.actions[key] = self.view_to_thing_action(rules, view)
204207

205208
def build_forms_for_view(self, rules: list, view: View, op: list):

0 commit comments

Comments
 (0)