Moved all API stuff to flask_labthings

This commit is contained in:
jtc42 2020-01-06 17:03:05 +00:00
parent 6bf178750b
commit 851d70842c
12 changed files with 96 additions and 109 deletions

View file

@ -1,12 +1,27 @@
from flask.views import MethodView
from openflexure_microscope.common.labthings_core.resource import BaseResource
class Resource(MethodView, BaseResource):
"""Currently identical to MethodView
class Resource(MethodView):
"""
A LabThing Resource class should make use of functions get(), put(), post(), and delete()
corresponding to HTTP methods.
These functions will allow for automated documentation generation
"""
methods = ["get", "post", "put", "delete"]
endpoint = None
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 BaseResource.methods:
if hasattr(self, meth) and hasattr(getattr(self, meth), "__apispec__"):
docs["operations"][meth] = {}
docs["operations"][meth] = getattr(self, meth).__apispec__
return docs