Cleaned code structure
This commit is contained in:
parent
79abc3fee3
commit
70149e9732
20 changed files with 196 additions and 332 deletions
20
openflexure_microscope/common/labthings_core/resource.py
Normal file
20
openflexure_microscope/common/labthings_core/resource.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class BaseResource:
|
||||
"""
|
||||
A LabThing Resource class should, regardless of the underlying framework, 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"]
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue