First draft of auto-Swagger

This commit is contained in:
jtc42 2020-01-02 21:33:50 +00:00
parent 99d0d0055e
commit 6d7921e8b4
8 changed files with 205 additions and 21 deletions

View file

@ -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