@@ -8,6 +8,7 @@ def _parse_document(data, base_url=None):
88 base_url = _get_document_base_url (data , base_url )
99 info = _get_dict (data , 'info' )
1010 title = _get_string (info , 'title' )
11+ description = _get_string (info , 'description' )
1112 consumes = get_strings (_get_list (data , 'consumes' ))
1213 paths = _get_dict (data , 'paths' )
1314 content = {}
@@ -21,9 +22,6 @@ def _parse_document(data, base_url=None):
2122 continue
2223 operation = _get_dict (spec , action )
2324
24- link_description = _get_string (operation , 'description' )
25- link_consumes = get_strings (_get_list (operation , 'consumes' , consumes ))
26-
2725 # Determine any fields on the link.
2826 has_body = False
2927 has_form = False
@@ -34,7 +32,6 @@ def _parse_document(data, base_url=None):
3432 name = _get_string (parameter , 'name' )
3533 location = _get_string (parameter , 'in' )
3634 required = _get_bool (parameter , 'required' , default = (location == 'path' ))
37- description = _get_string (parameter , 'description' )
3835 if location == 'body' :
3936 has_body = True
4037 schema = _get_dict (parameter , 'schema' , dereference_using = data )
@@ -47,22 +44,27 @@ def _parse_document(data, base_url=None):
4744 ]
4845 fields += expanded_fields
4946 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 )
5149 fields .append (field )
5250 else :
5351 if location == 'formData' :
5452 has_form = True
5553 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 )
5756 fields .append (field )
5857
58+ link_consumes = get_strings (_get_list (operation , 'consumes' , consumes ))
5959 encoding = ''
6060 if has_body :
6161 encoding = _select_encoding (link_consumes )
6262 elif has_form :
6363 encoding = _select_encoding (link_consumes , form = True )
6464
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 )
6668
6769 # Add the link to the document content.
6870 tags = get_strings (_get_list (operation , 'tags' ))
@@ -78,7 +80,13 @@ def _parse_document(data, base_url=None):
7880 else :
7981 content [operation_id ] = link
8082
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+ )
8290
8391
8492def _get_document_base_url (data , base_url = None ):
0 commit comments