Add some convenience methods

This commit is contained in:
Cristi Vîjdea
2018-09-11 02:40:20 +03:00
parent 90812f5c43
commit 27cd5f7f2a
3 changed files with 31 additions and 6 deletions
+11
View File
@@ -291,6 +291,8 @@ class Paths(SwaggerDict):
class PathItem(SwaggerDict):
OPERATION_NAMES = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch']
def __init__(self, get=None, put=None, post=None, delete=None, options=None,
head=None, patch=None, parameters=None, **extra):
"""Information about a single path
@@ -315,6 +317,15 @@ class PathItem(SwaggerDict):
self.parameters = filter_none(parameters)
self._insert_extras__()
@property
def operations(self):
"""A list of all standard Operations on this PathItem object. See :attr:`.OPERATION_NAMES`.
:return: list of (method name, Operation) tuples
:rtype: list[tuple[str,Operation]]
"""
return [(k, v) for k, v in self.items() if k in PathItem.OPERATION_NAMES and v]
class Operation(SwaggerDict):
def __init__(self, operation_id, responses, parameters=None, consumes=None, produces=None, summary=None,