-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschemas.py
44 lines (33 loc) · 1.37 KB
/
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
37
38
39
40
41
42
43
44
from marshmallow import fields,Schema
class PlainItemSchema(Schema):
item_id=fields.Int(dump_only=True)
name=fields.Str(required=True)
price=fields.Float(required=True)
class PlainStoreSchema(Schema):
store_id=fields.Int(dump_only=True)
name=fields.Str(required=True)
class PlainTagSchema(Schema):
tag_id=fields.Int(dump_only=True)
name=fields.Str(required=True)
class ItemSchema(PlainItemSchema):
store_id=fields.Int(required=True)
store=fields.Nested(PlainStoreSchema(),dump_only=True)
tags=fields.List(fields.Nested(PlainTagSchema()),dump_only=True)
class ItemUpdateSchema(Schema):
name=fields.Str()
price=fields.Float()
class StoreSchema(PlainStoreSchema):
Items=fields.List(fields.Nested(PlainItemSchema()),dump_only=True)
tags=fields.List(fields.Nested(PlainTagSchema()),dump_only=True)
class TagsSchema(PlainTagSchema):
store_id=fields.Int(load_only=True)
store=fields.Nested(PlainStoreSchema(),dump_only=True)
items=fields.List(fields.Nested(PlainItemSchema()),dump_only=True)
class ItemAndTagSchema(Schema):
message = fields.Str()
item = fields.Nested(ItemSchema)
tag = fields.Nested(TagsSchema)
class UserSchema(Schema):
user_id=fields.Int(dump_only=True)
username=fields.Str(required=True)
password=fields.Str(required=True,load_only=True)