Add get_schema method to Service class
This commit is contained in:
parent
0c025977ab
commit
beb8f9a393
1 changed files with 17 additions and 0 deletions
|
|
@ -5,6 +5,23 @@ class Service(ABC):
|
||||||
name: str
|
name: str
|
||||||
ready: bool = False
|
ready: bool = False
|
||||||
|
|
||||||
|
def get_schema(self):
|
||||||
|
"""Build a dictionary listing all methods, their parameters, types, return types and documentation."""
|
||||||
|
|
||||||
|
schema = {}
|
||||||
|
ignore = ["teardown", "set_ready"]
|
||||||
|
for method in dir(self):
|
||||||
|
if method.startswith("_") or method in ignore:
|
||||||
|
continue
|
||||||
|
func = getattr(self, method)
|
||||||
|
schema[method] = {
|
||||||
|
"name": method,
|
||||||
|
"parameters": func.__annotations__,
|
||||||
|
"return": func.__annotations__.get("return"),
|
||||||
|
"documentation": func.__doc__,
|
||||||
|
}
|
||||||
|
return schema
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue