@@ -132,6 +132,26 @@ def _get_field_format(field):
132
132
return field .schema and getattr (field .schema , 'format' , None )
133
133
134
134
135
+ def _get_property_type (the_schema ):
136
+ return {
137
+ coreschema .String : 'string' ,
138
+ coreschema .Integer : 'integer' ,
139
+ coreschema .Number : 'number' ,
140
+ coreschema .Boolean : 'boolean' ,
141
+ coreschema .Array : 'array' ,
142
+ coreschema .Object : 'object' ,
143
+ }.get (the_schema .__class__ , 'string' )
144
+
145
+
146
+ def _field_properties_for_fields (field__schema_properties ):
147
+ field_properties = {}
148
+ for k in field__schema_properties :
149
+ field_properties [k ] = {
150
+ 'type' : _get_property_type (field__schema_properties [k ])
151
+ }
152
+ return field_properties
153
+
154
+
135
155
def _get_parameters (link , encoding ):
136
156
"""
137
157
Generates Swagger Parameter Item object.
@@ -168,8 +188,28 @@ def _get_parameters(link, encoding):
168
188
'description' : field_description ,
169
189
'type' : field_type ,
170
190
}
191
+ if field_type == 'object' :
192
+ field_properties = _field_properties_for_fields (field .schema .properties )
193
+ schema_property = {
194
+ 'description' : field_description ,
195
+ 'type' : field_type ,
196
+ 'properties' : field_properties
197
+ }
171
198
if field_type == 'array' :
172
- schema_property ['items' ] = {'type' : 'string' }
199
+ if hasattr (field .schema .items , 'properties' ):
200
+ # the array contains object instances, we need to inspect their properties
201
+ field_properties = _field_properties_for_fields (
202
+ field .schema .items .properties
203
+ )
204
+ schema_property ['items' ] = {
205
+ 'type' : 'object' ,
206
+ 'properties' : field_properties
207
+ }
208
+ else :
209
+ # the array contains primitive types
210
+ schema_property ['items' ] = {
211
+ 'type' : _get_property_type (field .schema .items ),
212
+ }
173
213
properties [field .name ] = schema_property
174
214
if field .required :
175
215
required .append (field .name )
0 commit comments