Updated documentation to LT070 style
This commit is contained in:
parent
83b3ea1d1d
commit
9ae2ae06d0
12 changed files with 114 additions and 127 deletions
|
|
@ -2,12 +2,6 @@ from labthings.server.extensions import BaseExtension
|
|||
from labthings.server.find import find_component
|
||||
from labthings.server.view import View, PropertyView
|
||||
|
||||
from labthings.server.decorators import (
|
||||
use_args,
|
||||
marshal_with,
|
||||
ThingProperty,
|
||||
PropertySchema,
|
||||
)
|
||||
from labthings.server.schema import Schema
|
||||
from labthings.server import fields
|
||||
|
||||
|
|
@ -38,7 +32,8 @@ def rename(microscope, new_name):
|
|||
# Since we only have a GET method here, it'll register as a read-only property
|
||||
class ExampleIdentifyView(PropertyView):
|
||||
# Format our returned object using MicroscopeIdentifySchema
|
||||
@marshal_with(MicroscopeIdentifySchema())
|
||||
schema = MicroscopeIdentifySchema()
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
Show identifying information about the current microscope object
|
||||
|
|
@ -47,14 +42,15 @@ class ExampleIdentifyView(PropertyView):
|
|||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
# Return our microscope object,
|
||||
# let @marshal_with handle formatting the output
|
||||
# let schema handle formatting the output
|
||||
return microscope
|
||||
|
||||
|
||||
# We can use a single schema for all methods if the input and output will be formatted identically
|
||||
# Eg. Here, we will always expect a "name" string argument, and always return a "name" string attribute
|
||||
@PropertySchema({"name": fields.String(required=True, example="My Example Microscope")})
|
||||
# We can use a single schema as the input and output will be formatted identically
|
||||
# Eg. We always expect a "name" string argument, and always return a "name" string attribute
|
||||
class ExampleRenameView(PropertyView):
|
||||
schema = {"name": fields.String(required=True, example="My Example Microscope")}
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
Show the current microscope name
|
||||
|
|
@ -78,7 +74,7 @@ class ExampleRenameView(PropertyView):
|
|||
rename(microscope, new_name)
|
||||
|
||||
# Return our microscope object,
|
||||
# let @marshal_with handle formatting the output
|
||||
# let schema handle formatting the output
|
||||
return microscope
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue