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

Commit ee10517

Browse files
authored
Merge pull request #15 from core-api/include-descriptions
Include description, summary. Ensure methods are ordered.
2 parents 4c621c6 + 56e0ba6 commit ee10517

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
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.3'
11+
__version__ = '1.1.4'
1212

1313

1414
class OpenAPICodec(BaseCodec):

openapi_codec/encode.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _get_paths_object(document):
6666

6767
for operation_id, link, tags in links:
6868
if link.url not in paths:
69-
paths[link.url] = {}
69+
paths[link.url] = OrderedDict()
7070

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

7878
def _get_operation(operation_id, link, tags):
7979
encoding = get_encoding(link)
80+
description = link.description.strip()
81+
summary = description.splitlines()[0] if description else None
8082

8183
operation = {
8284
'operationId': operation_id,
83-
'description': link.description,
8485
'responses': _get_responses(link),
8586
'parameters': _get_parameters(link, encoding)
8687
}
88+
89+
if description:
90+
operation['description'] = description
91+
if summary:
92+
operation['summary'] = summary
8793
if encoding:
8894
operation['consumes'] = [encoding]
8995
if tags:

tests/test_encode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def test_paths(self):
6363
}
6464
},
6565
'parameters': [],
66-
'description': '',
6766
'operationId': 'list',
6867
'tags': ['users']
6968
}
@@ -75,7 +74,6 @@ def test_paths(self):
7574
}
7675
},
7776
'parameters': [],
78-
'description': '',
7977
'operationId': 'create',
8078
'tags': ['users']
8179
}

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