Now, we will create the Flask-Marshmallow schemas that we will use to validate, serialize, and deserialize the previously declared NotificationCategory and Notification models, and their relationships.
Open the models.py file within the service folder and add the following code after the last line. The lines that declare fields related to other schemas are highlighted in the code listing. The code file for the sample is included in the restful_python_2_02_01 folder, in the Flask01/service/models.py file:
class NotificationCategorySchema(ma.Schema): id = fields.Integer(dump_only=True) # Minimum length = 3 characters name = fields.String(required=True, validate=validate.Length(3)) ...