Add tags to openapi schemas

This commit is contained in:
Melon 2019-12-25 11:03:11 +07:00
parent d985c7cbb9
commit 6b8353d3d2

View File

@ -47,11 +47,13 @@ class SchemaGenerator(BaseSchemaGenerator):
operation = view.schema.get_operation(path, method) operation = view.schema.get_operation(path, method)
# Normalise path for any provided mount url. # Normalise path for any provided mount url.
if path.startswith('/'): if path.startswith('/'):
tags = [path.split('/')[1]]
path = path[1:] path = path[1:]
path = urljoin(self.url or '/', path) path = urljoin(self.url or '/', path)
result.setdefault(path, {}) result.setdefault(path, {})
result[path][method.lower()] = operation result[path][method.lower()] = operation
result[path][method.lower()].update(tags=tags)
return result return result