Fixed default response docs
This commit is contained in:
parent
6d7921e8b4
commit
b0316ae494
1 changed files with 13 additions and 2 deletions
|
|
@ -21,11 +21,22 @@ def view2path(rule: str, view: Resource, spec: APISpec):
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def view2operations(view: Resource, spec: APISpec):
|
def view2operations(view: Resource, spec: APISpec, populate_default: bool = True):
|
||||||
ops = {}
|
ops = {}
|
||||||
for method in Resource.methods:
|
for method in Resource.methods:
|
||||||
if hasattr(view, method):
|
if hasattr(view, method):
|
||||||
ops[method] = {}
|
|
||||||
|
if populate_default:
|
||||||
|
ops[method] = {
|
||||||
|
"responses": {
|
||||||
|
200: {
|
||||||
|
"description": "success"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
ops[method] = {}
|
||||||
|
|
||||||
if hasattr(getattr(view, method), "__apispec__"):
|
if hasattr(getattr(view, method), "__apispec__"):
|
||||||
ops[method] = doc2operation(getattr(view, method).__apispec__, spec)
|
ops[method] = doc2operation(getattr(view, method).__apispec__, spec)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue