4
4
5
5
from labthings .server .quick import create_app
6
6
from 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
8
8
9
9
from labthings .server .types import value_to_field , data_dict_to_schema
10
10
11
11
from components .pdf_component import PdfComponent
12
12
13
13
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
+ ):
15
17
16
18
# Create a class name
17
19
if not name :
@@ -57,6 +59,11 @@ def _put(self, args):
57
59
generated_class = PropertySchema (property_schema )(generated_class )
58
60
generated_class = ThingProperty (generated_class )
59
61
62
+ if description :
63
+ generated_class = Doc (description = description , summary = description )(
64
+ generated_class
65
+ )
66
+
60
67
return generated_class
61
68
62
69
@@ -74,8 +81,18 @@ def _put(self, args):
74
81
labthing .add_component (my_component , "org.labthings.example.mycomponent" )
75
82
76
83
# 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
+ )
79
96
80
97
# Start the app
81
98
if __name__ == "__main__" :
0 commit comments