RecipeSchema Design
So, we have done the serialization/deserialization for the User
object. Now we are going to design the schema for the Recipe
object. In the case of the Recipe
update, we will expect the user to fill in updated recipe details on a web form, and then send the details in JSON format to the server. Our Smilecook
application will then deserialize it to be a Recipe
object, which can be worked on in our application.
RecipeSchema
should inherit marshmallow.Schema
and contains the following attributes:
id
: Usefields.Int()
to represent an integer, and applydump_only=True
to specify that this property is only available for serialization.name
: Usefields.String()
to represent a string and applyrequired=True
to indicate that this attribute is required.description
: Usefields.String()
to represent a string.num_of_servings
: Usefields.Int()
to represent an integer.cook_time
: Usefields.Int()
to represent an integer.directions
: Usefields...