@@ -16,7 +16,7 @@ def find_schema_for_view(view: View):
1616 # If prop is read-only
1717 if hasattr (view , "get" ) and not (hasattr (view , "post" ) or hasattr (view , "put" )):
1818 # Use GET schema
19- prop_schema = get_spec (view .get ).get ("_schema" ).get (200 )
19+ prop_schema = get_spec (view .get ).get ("_schema" , {} ).get (200 )
2020 # If prop is write-only
2121 elif not hasattr (view , "get" ) and (hasattr (view , "post" ) or hasattr (view , "put" )):
2222 if hasattr (view , "post" ):
@@ -72,14 +72,15 @@ def view_to_thing_property(self, rules: list, view: View):
7272 if not prop_schema :
7373 prop_schema = find_schema_for_view (view )
7474
75- # Ensure valid schema type
76- prop_schema = convert_schema (prop_schema , self .apispec )
75+ if prop_schema :
76+ # Ensure valid schema type
77+ prop_schema = convert_schema (prop_schema , self .apispec )
7778
78- # Convert schema to JSON
79- prop_schema_json = schema_to_json (prop_schema , self .apispec )
79+ # Convert schema to JSON
80+ prop_schema_json = schema_to_json (prop_schema , self .apispec )
8081
81- # Add schema to prop description
82- prop_description .update (prop_schema_json )
82+ # Add schema to prop description
83+ prop_description .update (prop_schema_json )
8384
8485 # Add URI variables
8586 for prop_rule in rules :
@@ -110,4 +111,4 @@ def property(self, rules: list, view: View):
110111 self .properties .append (self .view_to_thing_property (rules , view ))
111112
112113 def action (self , rules : list , view : View ):
113- self .properties .append (self .view_to_thing_action (rules , view ))
114+ self .actions .append (self .view_to_thing_action (rules , view ))
0 commit comments