-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
30 lines (21 loc) · 817 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
from marshmallow import Schema, fields
class PlainItemSchema(Schema):
id = fields.Str(dump_only=True)
name = fields.Str(required=True)
price = fields.Float(required=True)
class PlainStoreSchema(Schema):
id = fields.Str(dump_only=True)
name = fields.Str(required=True)
class UpdateItemSchema(Schema):
price = fields.Float()
name = fields.Str()
store_id = fields.Int()
class ItemSchema(PlainItemSchema):
store_id = fields.Int(required=True, load_only=True)
store = fields.Nested(PlainStoreSchema(), dump_only=True)
class StoreSchema(PlainStoreSchema):
items = fields.List(fields.Nested(PlainItemSchema()), dump_only=True)
class UserSchema(Schema):
id = fields.Str(dump_only=True)
username = fields.Str(required=True)
password = fields.Str(required=True)