From 5d977d8ae37a5453fe131418498c40fd4cbdf2e7 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 5 Oct 2016 14:49:39 +0100 Subject: [PATCH 1/2] Include description, summary. Ensure methods are ordered. --- openapi_codec/__init__.py | 2 +- openapi_codec/encode.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openapi_codec/__init__.py b/openapi_codec/__init__.py index 342bec1..f9d8ec1 100644 --- a/openapi_codec/__init__.py +++ b/openapi_codec/__init__.py @@ -8,7 +8,7 @@ from openapi_codec.decode import _parse_document -__version__ = '1.1.3' +__version__ = '1.1.4' class OpenAPICodec(BaseCodec): diff --git a/openapi_codec/encode.py b/openapi_codec/encode.py index 4fc3bcd..a95aaed 100644 --- a/openapi_codec/encode.py +++ b/openapi_codec/encode.py @@ -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) @@ -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: From 56e0ba697a5334ffe2e5e7a937002ff7fc4ed625 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 5 Oct 2016 15:11:38 +0100 Subject: [PATCH 2/2] Update tests --- tests/test_encode.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_encode.py b/tests/test_encode.py index d50d226..8bd7a72 100644 --- a/tests/test_encode.py +++ b/tests/test_encode.py @@ -63,7 +63,6 @@ def test_paths(self): } }, 'parameters': [], - 'description': '', 'operationId': 'list', 'tags': ['users'] } @@ -75,7 +74,6 @@ def test_paths(self): } }, 'parameters': [], - 'description': '', 'operationId': 'create', 'tags': ['users'] } 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