44
55from labthings .server .quick import create_app
66from labthings .server .view import View
7- from labthings .server .decorators import ThingProperty , PropertySchema , use_args
7+ from labthings .server .decorators import ThingProperty , PropertySchema , use_args , Doc
88
99from labthings .server .types import value_to_field , data_dict_to_schema
1010
1111from components .pdf_component import PdfComponent
1212
1313
14- def gen_property (property_object , property_name , name : str = None , readonly = False ):
14+ def gen_property (
15+ property_object , property_name , name : str = None , readonly = False , description = None
16+ ):
1517
1618 # Create a class name
1719 if not name :
@@ -57,6 +59,11 @@ def _put(self, args):
5759 generated_class = PropertySchema (property_schema )(generated_class )
5860 generated_class = ThingProperty (generated_class )
5961
62+ if description :
63+ generated_class = Doc (description = description , summary = description )(
64+ generated_class
65+ )
66+
6067 return generated_class
6168
6269
@@ -74,8 +81,18 @@ def _put(self, args):
7481labthing .add_component (my_component , "org.labthings.example.mycomponent" )
7582
7683# Add routes for the API views we created
77- labthing .add_view (gen_property (my_component , "magic_denoise" ), "/denoise" )
78- labthing .add_view (gen_property (my_component , "magic_dictionary" ), "/dictionary" )
84+ labthing .add_view (
85+ gen_property (my_component , "magic_denoise" , description = "A magic denoise property" ),
86+ "/denoise" ,
87+ )
88+ labthing .add_view (
89+ gen_property (
90+ my_component ,
91+ "magic_dictionary" ,
92+ description = "A big dictionary of little properties" ,
93+ ),
94+ "/dictionary" ,
95+ )
7996
8097# Start the app
8198if __name__ == "__main__" :
0 commit comments