-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschemas.py
36 lines (23 loc) · 937 Bytes
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from marshmallow import Schema, fields
class RecipeSchema(Schema):
directions = fields.Nested('DirectionSchema', many=True)
ingredients = fields.Nested('IngredientSchema', many=True)
categories = fields.Nested('CategorySchema', many=True)
class Meta:
fields = ('id', 'title', 'quantity', 'created_at',
'directions', 'ingredients', 'categories')
class DirectionSchema(Schema):
class Meta:
fields = ('step', )
class IngredientSchema(Schema):
class Meta:
fields = ('quantity', 'unit', 'item')
class CategorySchema(Schema):
class Meta:
fields = ('title', )
# https://pythonhosted.org/Flask-SQLAlchemy/api.html#flask.ext.sqlalchemy.Pagination
class PaginationSchema(Schema):
items = fields.Nested('RecipeSchema', many=True)
class Meta:
fields = ('has_next', 'has_prev', 'items', 'page',
'pages', 'per_page', 'total')