Enable tag inheritance

This commit is contained in:
Joel Collins 2020-01-07 21:23:42 +00:00
parent ed13749abe
commit eaf2fc5f7d
3 changed files with 17 additions and 1 deletions

View file

@ -37,6 +37,12 @@ def view2path(rule: str, view: Resource, spec: APISpec):
def view2operations(view: Resource, spec: APISpec):
# Operations inherit tags from parent
inherited_tags = []
if hasattr(view, "__apispec__"):
inherited_tags = getattr(view, "__apispec__").get("tags", [])
# Build dictionary of operations (HTTP methods)
ops = {}
for method in Resource.methods:
if hasattr(view, method):
@ -47,6 +53,7 @@ def view2operations(view: Resource, spec: APISpec):
{
"description": get_docstring(getattr(view, method)),
"summary": get_summary(getattr(view, method)),
"tags": inherited_tags,
},
)