8000 Include description, summary. Ensure methods are ordered. by tomchristie · Pull Request #15 · core-api/python-openapi-codec · GitHub
[go: up one dir, main page]

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

Include description, summary. Ensu 8000 re methods are ordered. #15

Merged
merged 2 commits into from
Oct 5, 2016
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 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.3'
__version__ = '1.1.4'


class OpenAPICodec(BaseCodec):
Expand Down
10 changes: 8 additions & 2 deletions openapi_codec/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _get_paths_object(document):

for operation_id, link, tags in links:
if link.url not in paths:
paths[link.url] = {}
paths[link.url] = OrderedDict()

method = get_method(link)
operation = _get_operation(operation_id, link, tags)
Expand All @@ -77,13 +77,19 @@ def _get_paths_object(document):

def _get_operation(operation_id, link, tags):
encoding = get_encoding(link)
description = link.description.strip()
summary = description.splitlines()[0] if description else None

operation = {
'operationId': operation_id,
'description': link.description,
'responses': _get_responses(link),
'parameters': _get_parameters(link, encoding)
}

if description:
operation['description'] = description
if summary:
operation['summary'] = summary
if encoding:
operation['consumes'] = [encoding]
if tags:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def test_paths(self):
}
},
'parameters': [],
'description': '',
'operationId': 'list',
'tags': ['users']
}
Expand All @@ -75,7 +74,6 @@ def test_paths(self):
}
},
'parameters': [],
'description': '',
'operationId': 'create',
'tags': ['users']
}
Expand Down
0