Add a test for operation name collisions and fix the one additional collision found
This commit is contained in:
parent
932fa56227
commit
aa2704acc7
3 changed files with 12 additions and 4 deletions
|
@ -65,6 +65,7 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
models = {}
|
||||
tags = []
|
||||
tags_added = set()
|
||||
operationIds = set()
|
||||
|
||||
for rule in app.url_map.iter_rules():
|
||||
endpoint_method = app.view_functions[rule.endpoint]
|
||||
|
@ -125,13 +126,20 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
logger.debug('Unable to find method for %s in class %s', method_name, view_class)
|
||||
continue
|
||||
|
||||
operationId = method_metadata(method, 'nickname')
|
||||
operation_swagger = {
|
||||
'operationId': method_metadata(method, 'nickname'),
|
||||
'operationId': operationId,
|
||||
'parameters': [],
|
||||
}
|
||||
if operation_swagger['operationId'] is None:
|
||||
|
||||
if operationId is None:
|
||||
continue
|
||||
|
||||
if operationId in operationIds:
|
||||
raise Exception('Duplicate operation Id: %s' % operationId)
|
||||
|
||||
operationIds.add(operationId)
|
||||
|
||||
if not compact:
|
||||
operation_swagger.update({
|
||||
'description': method.__doc__.strip() if method.__doc__ else '',
|
||||
|
|
Reference in a new issue