-
Notifications
You must be signed in to change notification settings - Fork 1
/
schemas.py
31 lines (21 loc) · 831 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
from marshmallow import Schema, fields
class PlainCitySchema(Schema):
id = fields.Int(dump_only=True)
name = fields.Str(required=True)
class PlainStateSchema(Schema):
id = fields.Int(dump_only=True)
name = fields.Str()
class CitySchema(PlainCitySchema):
state_id = fields.Int(required=True, load_only=True)
state = fields.Nested(PlainStateSchema(), dump_only=True)
class CityUpdateSchema(Schema):
name = fields.Str()
state_id = fields.Int()
class StateSchema(PlainStateSchema):
cities = fields.List(fields.Nested(PlainStateSchema()), dump_only=True)
class UserSchema(Schema):
id = fields.Int(dump_only=True)
username = fields.Str(required=True)
password = fields.Str(required=True, load_only=True)
class UserRegisterSchema(UserSchema):
email = fields.Str(required=True)