@@ -61,12 +61,12 @@ def expand_schema(schema):
61
61
name = key ,
62
62
location = 'form' ,
63
63
required = schema_properties .get ('required' , key in schema_required ),
64
- description = schema_properties [key ].get ('description' )
64
+ description = schema_properties [key ].get ('description' , '' )
65
65
))
66
66
return fields
67
67
68
68
# If the schema is not type="object", then return a single field.
69
- return coreapi .Field (name = 'data' , location = 'body' , required = True )
69
+ return coreapi .Field (name = 'data' , location = 'body' , required = True , description = schema . get ( 'description' , '' ) )
70
70
71
71
72
72
def decode_raml (bytestring , base_url = None ):
@@ -82,19 +82,19 @@ def decode_raml(bytestring, base_url=None):
82
82
encoding = ''
83
83
84
84
for param in resource .uri_params or []:
85
- field = coreapi .Field (param .name , param .required , location = 'path' )
85
+ field = coreapi .Field (param .name , param .required , location = 'path' , description = param . description )
86
86
fields .append (field )
87
87
88
88
for param in resource .query_params or []:
89
- field = coreapi .Field (param .name , param .required , location = 'query' )
89
+ field = coreapi .Field (param .name , param .required , location = 'query' , description = param . description )
90
90
fields .append (field )
91
91
92
92
if resource .body :
93
93
body = resource .body [0 ]
94
94
encoding = body .mime_type
95
95
96
96
for form_param in body .form_params or []:
97
- field = coreapi .Field (param .name , param .required , location = 'form' )
97
+ field = coreapi .Field (param .name , param .required , location = 'form' , description = param . description )
98
98
fields .append (field )
99
99
100
100
if body .schema :
@@ -105,8 +105,13 @@ def decode_raml(bytestring, base_url=None):
105
105
url = resource .absolute_uri ,
106
106
action = resource .method .lower (),
107
107
encoding = encoding ,
108
- fields = fields
108
+ fields = fields ,
109
+ title = resource .display_name ,
110
+ description = str (resource .description ) if resource .description else ''
109
111
)
110
112
content [resource .display_name ] = link
111
113
112
- return coreapi .Document (title = raml .title , url = base_url , content = content )
114
+ description = ''
115
+ if raml .documentation :
116
+ description = str (raml .documentation [0 ].content )
117
+ return coreapi .Document (title = raml .title , url = base_url , content = content , description = description , media_type = 'application/raml+yaml' )
0 commit comments