Skip to content

Commit a072a37

Browse files
committed
🎨 (Marshmallow) Undo changes to schemas in Smorest project
Using `PlainItemSchema` and `PlainStoreSchema` as names for schemas that don't have `Nested` fields makes sense, but in this project we don't have `Nested` fields, so it feels difficult to justify. We will adopt this naming convention in the following section, when we do have nesting.
1 parent 21ca905 commit a072a37

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
from marshmallow import Schema, fields
22

33

4-
class PlainItemSchema(Schema):
5-
id = fields.Int(dump_only=True)
4+
class ItemSchema(Schema):
5+
id = fields.Str(dump_only=True)
66
name = fields.Str(required=True)
77
price = fields.Float(required=True)
8-
9-
10-
class PlainStoreSchema(Schema):
11-
id = fields.Int(dump_only=True)
12-
name = fields.Str()
13-
14-
15-
class ItemSchema(PlainItemSchema):
16-
store_id = fields.Int(required=True, load_only=True)
17-
store = fields.Nested(lambda: PlainStoreSchema(), dump_only=True)
8+
store_id = fields.Int(required=True)
189

1910

2011
class ItemUpdateSchema(Schema):
2112
name = fields.Str()
2213
price = fields.Float()
2314

2415

25-
class StoreSchema(PlainStoreSchema):
26-
items = fields.List(fields.Nested(PlainItemSchema()), dump_only=True)
16+
class StoreSchema(Schema):
17+
id = fields.Str(dump_only=True)
18+
name = fields.Str(required=True)

0 commit comments

Comments
 (0)