First draft of auto-Swagger
This commit is contained in:
parent
99d0d0055e
commit
6d7921e8b4
8 changed files with 205 additions and 21 deletions
|
|
@ -5,6 +5,19 @@ class Resource(MethodView):
|
|||
"""Currently identical to MethodView
|
||||
"""
|
||||
endpoint = None
|
||||
methods = ["get", "post", "put", "delete"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
MethodView.__init__(self, *args, **kwargs)
|
||||
|
||||
def doc(self):
|
||||
docs = {"operations": {}}
|
||||
if hasattr(self, "__apispec__"):
|
||||
docs.update(self.__apispec__)
|
||||
|
||||
|
||||
for meth in Resource.methods:
|
||||
if hasattr(self, meth) and hasattr(getattr(self, meth), "__apispec__"):
|
||||
docs["operations"][meth] = {}
|
||||
docs["operations"][meth] = getattr(self, meth).__apispec__
|
||||
return docs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue