forked from hpusset/marshmallow-jsonschema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schemas.py
executable file
·37 lines (27 loc) · 862 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
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from marshmallow_jsonschema import dump_schema
from marshmallow import Schema, fields, pprint
class Article(Schema):
name = fields.String()
price = fields.Int()
number = fields.Int()
class Order(Schema):
price = fields.Int()
articles = fields.Nested(Article, many=True, required=True)
class Address(Schema):
street = fields.String()
postal_code = fields.String()
class Person(Schema):
firstname = fields.String()
lastname = fields.String()
billing_address = fields.Nested(Address)
delevery_address = fields.Nested(Address)
other_addresses = fields.Nested(Address, many=True)
if __name__ == "__main__":
p = Person()
o = Order()
result_person = dump_schema(p)
result_order = dump_schema(o)
pprint(result_person)
pprint(result_order)