Expose tags in Operation object

This commit is contained in:
Marcin Molenda 2018-08-31 16:57:53 +02:00
parent 82a24f7ec4
commit e5cb549ea1
3 changed files with 7 additions and 4 deletions

View file

@ -31,6 +31,7 @@ class OperationsGenerator(object):
parameters = self.parameters_generator.generate_from_list(
parameters_list)
operation_id = operation_deref.get('operationId')
tags_list = operation_deref.get('tags', [])
request_body = None
if 'requestBody' in operation_deref:
@ -43,7 +44,7 @@ class OperationsGenerator(object):
Operation(
http_method, path_name, responses, list(parameters),
request_body=request_body, deprecated=deprecated,
operation_id=operation_id,
operation_id=operation_id, tags=list(tags_list)
),
)

View file

@ -8,7 +8,7 @@ class Operation(object):
def __init__(
self, http_method, path_name, responses, parameters,
request_body=None, deprecated=False, operation_id=None):
request_body=None, deprecated=False, operation_id=None, tags=None):
self.http_method = http_method
self.path_name = path_name
self.responses = dict(responses)
@ -16,6 +16,7 @@ class Operation(object):
self.request_body = request_body
self.deprecated = deprecated
self.operation_id = operation_id
self.tags = tags
def __getitem__(self, name):
return self.parameters[name]

View file

@ -73,12 +73,13 @@ class TestPetstore(object):
assert path.name == path_name
for http_method, operation in iteritems(path.operations):
operation_spec = spec_dict['paths'][path_name][http_method]
assert type(operation) == Operation
assert operation.path_name == path_name
assert operation.http_method == http_method
assert operation.operation_id is not None
operation_spec = spec_dict['paths'][path_name][http_method]
assert operation.tags == operation_spec['tags']
responses_spec = operation_spec.get('responses')