Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 openapi_codec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from openapi_codec.decode import _parse_document


__version__ = '1.1.7'
__version__ = '1.2.0'


class OpenAPICodec(BaseCodec):
Expand Down
24 changes: 16 additions & 8 deletions 24 openapi_codec/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def _parse_document(data, base_url=None):
base_url = _get_document_base_url(data, base_url)
info = _get_dict(data, 'info')
title = _get_string(info, 'title')
description = _get_string(info, 'description')
consumes = get_strings(_get_list(data, 'consumes'))
paths = _get_dict(data, 'paths')
content = {}
Expand All @@ -21,9 +22,6 @@ def _parse_document(data, base_url=None):
continue
operation = _get_dict(spec, action)

link_description = _get_string(operation, 'description')
link_consumes = get_strings(_get_list(operation, 'consumes', consumes))

# Determine any fields on the link.
has_body = False
has_form = False
Expand All @@ -34,7 +32,6 @@ def _parse_document(data, base_url=None):
name = _get_string(parameter, 'name')
location = _get_string(parameter, 'in')
required = _get_bool(parameter, 'required', default=(location == 'path'))
description = _get_string(parameter, 'description')
if location == 'body':
has_body = True
schema = _get_dict(parameter, 'schema', dereference_using=data)
Expand All @@ -47,22 +44,27 @@ def _parse_document(data, base_url=None):
]
fields += expanded_fields
else:
field = Field(name=name, location='body', required=required, description=description)
field_description = _get_string(parameter, 'description')
field = Field(name=name, location='body', required=required, description=field_description)
fields.append(field)
else:
if location == 'formData':
has_form = True
location = 'form'
field = Field(name=name, location=location, required=required, description=description)
field_description = _get_string(parameter, 'description')
field = Field(name=name, location=location, required=required, description=field_description)
fields.append(field)

link_consumes = get_strings(_get_list(operation, 'consumes', consumes))
encoding = ''
if has_body:
encoding = _select_encoding(link_consumes)
elif has_form:
encoding = _select_encoding(link_consumes, form=True)

link = Link(url=url, action=action, encoding=encoding, fields=fields, description=link_description)
link_title = _get_string(operation, 'summary')
link_description = _get_string(operation, 'description')
link = Link(url=url, action=action, encoding=encoding, fields=fields, title=link_title, description=link_description)

# Add the link to the document content.
tags = get_strings(_get_list(operation, 'tags'))
Expand All @@ -78,7 +80,13 @@ def _parse_document(data, base_url=None):
else:
content[operation_id] = link

return Document(url=schema_url, title=title, content=content)
return Document(
url=schema_url,
title=title,
description=description,
content=content,
media_type='application/openapi+json'
)


def _get_document_base_url(data, base_url=None):
Expand Down
2 changes: 1 addition & 1 deletion 2 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_package_data(package):
author_email='tom@tomchristie.com',
packages=get_packages('openapi_codec'),
package_data=get_package_data('openapi_codec'),
install_requires=['coreapi'],
install_requires=['coreapi>=2.1.0'],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.