Start explicit metadata argument for marshmallow

A side effect of re-locking dependencies is having a newer marshmallow.
This deprecates having `description=` as a keyword, and puts it in a
separate metadata arg instead.

This commit is the start of my search-and-replaceing to update to the new
format.
This commit is contained in:
Richard Bowman 2022-08-09 12:52:57 +01:00
parent 78ef9c531b
commit e22f36b308
14 changed files with 58 additions and 58 deletions

View file

@ -18,7 +18,7 @@ Like properties, we use a special view class to identify a view as an action: ``
Take an image capture and return it without saving
"""
# Expect a "use_video_port" boolean, which defaults to True if none is given
args = {"use_video_port": fields.Boolean(missing=True)}
args = {"use_video_port": fields.Boolean(load_default=True)}
# Our success response (200) returns an image (image/jpeg mimetype)
responses = {

View file

@ -91,7 +91,7 @@ class QuickCaptureAPI(ActionView):
"""
# Expect a "use_video_port" boolean, which defaults to True if none is given
args = {"use_video_port": fields.Boolean(missing=True)}
args = {"use_video_port": fields.Boolean(load_default=True)}
# Our success response (200) returns an image (image/jpeg mimetype)
responses = {200: {"content": {"image/jpeg": {}}}}

View file

@ -69,7 +69,7 @@ class TimelapseAPIView(ActionView):
required=True, example=5, description="Number of images"
),
"t_between": fields.Number(
missing=1, example=1, description="Time (seconds) between images"
load_default=1, example=1, description="Time (seconds) between images"
),
}

View file

@ -102,7 +102,7 @@ class TimelapseAPIView(ActionView):
required=True, example=5, description="Number of images"
),
"t_between": fields.Number(
missing=1, example=1, description="Time (seconds) between images"
load_default=1, example=1, description="Time (seconds) between images"
),
}

View file

@ -23,7 +23,7 @@ A **field** describes the data type of a single parameter, as well as any other
.. code-block:: python
fields.String(required=False, missing="Default value", example="Example value")
fields.String(required=False, load_default="Default value", example="Example value")
A **schema** is a collection of keys and fields describing how an object should be serialized/deserialized. Schemas can be created in several ways, either by creating a ``Schema`` class, or by passing a dictionary of key-field pairs. Both methods will be discussed in the following examples.
@ -43,7 +43,7 @@ For example, if you are creating an API route, in which you expect parameters ``
class UserSchema(Schema):
name = fields.String(required=True)
age = fields.Integer(required=True)
job = fields.String(required=False, missing="Unknown")
job = fields.String(required=False, load_default="Unknown")
To inform your POST method to expect these arguments, use the ``args`` class attribute:
@ -63,7 +63,7 @@ Alternatively, if your schema is only used in a single location, it may be simpl
args = {
"name": fields.String(required=True),
"age": fields.Integer(required=True),
"job": fields.String(required=False, missing="Unknown")
"job": fields.String(required=False, load_default="Unknown")
}
def post(self, args):
@ -88,7 +88,7 @@ This JSON data is the parsed, converted into a Python dictionary, and passed as
args = {
"name": fields.String(required=True),
"age": fields.Integer(required=True),
"job": fields.String(required=False, missing="Unknown")
"job": fields.String(required=False, load_default="Unknown")
}
def post(self, args):