-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
35 lines (23 loc) · 918 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
from marshmallow import Schema, fields
class UserLoginSchema(Schema):
email = fields.Email(required=True)
password = fields.Str(required=True, load_only=True)
class PlainUserSchema(Schema):
id = fields.Int(dump_only=True)
email = fields.Str(required=True)
password = fields.Str(load_only=True)
class PlainBookSchema(Schema):
id = fields.Int(dump_only=True)
title = fields.Str(required=True)
author = fields.Str()
dewey_decimal = fields.Int()
isbn = fields.Str()
class UserSchema(PlainUserSchema):
books = fields.List(fields.Nested(PlainBookSchema()), many=True, dump_only=True)
class BookSchema(PlainBookSchema):
users = fields.List(fields.Nested(PlainUserSchema()), many=True, dump_only=True)
class UserAndBookSchema(Schema):
title = fields.Str()
author = fields.Str()
class FileUploadResponseSchema(Schema):
filename = fields.Str(required=True)