@@ -111,7 +111,7 @@ def view_to_thing_property(self, rules: list, view: View):
111111
112112 # Basic description
113113 prop_description = {
114- "title" : getattr (view , "title" ) or view .__name__ ,
114+ "title" : getattr (view , "title" , None ) or view .__name__ ,
115115 "description" : get_docstring (view ),
116116 "readOnly" : not (
117117 hasattr (view , "post" ) or hasattr (view , "put" ) or hasattr (view , "delete" )
@@ -123,7 +123,7 @@ def view_to_thing_property(self, rules: list, view: View):
123123 }
124124
125125 # Look for a _propertySchema in the Property classes API SPec
126- prop_schema = getattr (view , "schema" )
126+ prop_schema = getattr (view , "schema" , None )
127127
128128 if prop_schema :
129129 # Ensure valid schema type
@@ -157,15 +157,15 @@ def view_to_thing_action(self, rules: list, view: View):
157157
158158 # Basic description
159159 action_description = {
160- "title" : getattr (view , "title" ) or view .__name__ ,
160+ "title" : getattr (view , "title" , None ) or view .__name__ ,
161161 "description" : get_docstring (view ),
162162 "links" : [{"href" : f"{ url } " } for url in action_urls ],
163- "safe" : getattr (view , "safe" ),
164- "idempotent" : getattr (view , "idempotent" ),
163+ "safe" : getattr (view , "safe" , False ),
164+ "idempotent" : getattr (view , "idempotent" , False ),
165165 }
166166
167167 # Look for a _params in the Action classes API Spec
168- action_input_schema = getattr (view , "args" )
168+ action_input_schema = getattr (view , "args" , None )
169169 if action_input_schema :
170170 # Ensure valid schema type
171171 action_input_schema = convert_to_schema_or_json (
@@ -178,7 +178,7 @@ def view_to_thing_action(self, rules: list, view: View):
178178 action_description ["input" ].update (get_semantic_type (view ))
179179
180180 # Look for a _schema in the Action classes API Spec
181- action_output_schema = getattr (view , "schema" )
181+ action_output_schema = getattr (view , "schema" , None )
182182 if action_output_schema :
183183 # Ensure valid schema type
184184 action_output_schema = convert_to_schema_or_json (
@@ -192,7 +192,7 @@ def view_to_thing_action(self, rules: list, view: View):
192192 return action_description
193193
194194 def property (self , rules : list , view : View ):
195- endpoint = getattr (view , "endpoint" ) or getattr (rules [0 ], "endpoint" )
195+ endpoint = getattr (view , "endpoint" , None ) or getattr (rules [0 ], "endpoint" )
196196 key = snake_to_camel (endpoint )
197197 self .properties [key ] = self .view_to_thing_property (rules , view )
198198
@@ -206,7 +206,7 @@ def action(self, rules: list, view: View):
206206 raise AttributeError (
207207 f"The API View '{ view } ' was added as an Action, but it does not have a POST method."
208208 )
209- endpoint = getattr (view , "endpoint" ) or getattr (rules [0 ], "endpoint" )
209+ endpoint = getattr (view , "endpoint" , None ) or getattr (rules [0 ], "endpoint" )
210210 key = snake_to_camel (endpoint )
211211 self .actions [key ] = self .view_to_thing_action (rules , view )
212212
0 commit comments