Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit 565f902

Browse files
authored
Merge pull request #26 from core-api/version-1-2-0
Version 1.2.0
2 parents ab197b7 + 573f32d commit 565f902

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

openapi_codec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from openapi_codec.decode import _parse_document
99

1010

11-
__version__ = '1.1.7'
11+
__version__ = '1.2.0'
1212

1313

1414
class OpenAPICodec(BaseCodec):

openapi_codec/decode.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8492
def _get_document_base_url(data, base_url=None):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_package_data(package):
6161
author_email='tom@tomchristie.com',
6262
packages=get_packages('openapi_codec'),
6363
package_data=get_package_data('openapi_codec'),
64-
install_requires=['coreapi'],
64+
install_requires=['coreapi>=2.1.0'],
6565
classifiers=[
6666
'Intended Audience :: Developers',
6767
'License :: OSI Approved :: BSD License',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy