|
1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
2
|
|
|
# TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this file |
|
|
|
|
|
|
3
|
|
|
import marshmallow |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
class NoContentSchema(marshmallow.Schema): |
|
|
|
|
|
|
7
|
|
|
pass |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class AboutResponseSchema(marshmallow.Schema): |
|
|
|
|
|
|
11
|
|
|
version = marshmallow.fields.String(required=True,) |
|
12
|
|
|
datetime = marshmallow.fields.DateTime(required=True) |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class UserPathSchema(marshmallow.Schema): |
|
|
|
|
|
|
16
|
|
|
id = marshmallow.fields.Int( |
|
|
|
|
|
|
17
|
|
|
required=True, |
|
18
|
|
|
validate=marshmallow.validate.Range(min=1), |
|
19
|
|
|
) |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class UserSchema(marshmallow.Schema): |
|
|
|
|
|
|
23
|
|
|
id = marshmallow.fields.Int(required=True) |
|
|
|
|
|
|
24
|
|
|
username = marshmallow.fields.String( |
|
25
|
|
|
required=True, |
|
26
|
|
|
validate=marshmallow.validate.Regexp(regex='[\w-]+'), |
|
|
|
|
|
|
27
|
|
|
) |
|
28
|
|
|
email_address = marshmallow.fields.Email(required=True) |
|
29
|
|
|
first_name = marshmallow.fields.String(required=True) |
|
30
|
|
|
last_name = marshmallow.fields.String(required=True) |
|
31
|
|
|
display_name = marshmallow.fields.String(required=True) |
|
32
|
|
|
company = marshmallow.fields.String(required=True) |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
class PaginationSchema(marshmallow.Schema): |
|
|
|
|
|
|
36
|
|
|
first_id = marshmallow.fields.Int(required=True) |
|
37
|
|
|
last_id = marshmallow.fields.Int(required=True) |
|
38
|
|
|
current_id = marshmallow.fields.Int(required=True) |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
class ListsUserSchema(marshmallow.Schema): |
|
|
|
|
|
|
42
|
|
|
item_nb = marshmallow.fields.Int( |
|
43
|
|
|
required=True, |
|
44
|
|
|
validate=marshmallow.validate.Range(min=0) |
|
45
|
|
|
) |
|
46
|
|
|
items = marshmallow.fields.Nested( |
|
47
|
|
|
UserSchema, |
|
48
|
|
|
many=True, |
|
49
|
|
|
only=['id', 'username', 'display_name', 'company'] |
|
50
|
|
|
) |
|
51
|
|
|
# TODO - G.M - 2017-12-05 - Fix nested schema import into doc ! |
|
|
|
|
|
|
52
|
|
|
# Can't add doc for nested Schema properly |
|
53
|
|
|
# When schema item isn't added through their own method |
|
54
|
|
|
# Ex : Pagination Schema doesn't work here but UserSchema is ok. |
|
55
|
|
|
pagination = marshmallow.fields.Nested( |
|
56
|
|
|
PaginationSchema |
|
57
|
|
|
) |
|
58
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.