@@ -8,6 +8,7 @@ def _parse_document(data, base_url=None):
8
8
base_url = _get_document_base_url (data , base_url )
9
9
info = _get_dict (data , 'info' )
10
10
title = _get_string (info , 'title' )
11
+ description = _get_string (info , 'description' )
11
12
consumes = get_strings (_get_list (data , 'consumes' ))
12
13
paths = _get_dict (data , 'paths' )
13
14
content = {}
@@ -21,9 +22,6 @@ def _parse_document(data, base_url=None):
21
22
continue
22
23
operation = _get_dict (spec , action )
23
24
24
- link_description = _get_string (operation , 'description' )
25
- link_consumes = get_strings (_get_list (operation , 'consumes' , consumes ))
26
-
27
25
# Determine any fields on the link.
28
26
has_body = False
29
27
has_form = False
@@ -34,7 +32,6 @@ def _parse_document(data, base_url=None):
34
32
name = _get_string (parameter , 'name' )
35
33
location = _get_string (parameter , 'in' )
36
34
required = _get_bool (parameter , 'required' , default = (location == 'path' ))
37
- description = _get_string (parameter , 'description' )
38
35
if location == 'body' :
39
36
has_body = True
40
37
schema = _get_dict (parameter , 'schema' , dereference_using = data )
@@ -47,22 +44,27 @@ def _parse_document(data, base_url=None):
47
44
]
48
45
fields += expanded_fields
49
46
else :
50
- field = Field (name = name , location = 'body' , required = required , description = description )
47
+ field_description = _get_string (parameter , 'description' )
48
+ field = Field (name = name , location = 'body' , required = required , description = field_description )
51
49
fields .append (field )
52
50
else :
53
51
if location == 'formData' :
54
52
has_form = True
55
53
location = 'form'
56
- field = Field (name = name , location = location , required = required , description = description )
54
+ field_description = _get_string (parameter , 'description' )
55
+ field = Field (name = name , location = location , required = required , description = field_description )
57
56
fields .append (field )
58
57
58
+ link_consumes = get_strings (_get_list (operation , 'consumes' , consumes ))
59
59
encoding = ''
60
60
if has_body :
61
61
encoding = _select_encoding (link_consumes )
62
62
elif has_form :
63
63
encoding = _select_encoding (link_consumes , form = True )
64
64
65
- link = Link (url = url , action = action , encoding = encoding , fields = fields , description = link_description )
65
+ link_title = _get_string (operation , 'summary' )
66
+ link_description = _get_string (operation , 'description' )
67
+ link = Link (url = url , action = action , encoding = encoding , fields = fields , title = link_title , description = link_description )
66
68
67
69
# Add the link to the document content.
68
70
tags = get_strings (_get_list (operation , 'tags' ))
@@ -78,7 +80,13 @@ def _parse_document(data, base_url=None):
78
80
else :
79
81
content [operation_id ] = link
80
82
81
- return Document (url = schema_url , title = title , content = content )
83
+ return Document (
84
+ url = schema_url ,
85
+ title = title ,
86
+ description = description ,
87
+ content = content ,
88
+ media_type = 'application/openapi+json'
89
+ )
82
90
83
91
84
92
def _get_document_base_url (data , base_url = None ):
0 commit comments