class Recipe(ModelResource): class Schema: name = fields.String() class Meta: model = 'recipe' manager = MemoryManager id_field_class = fields.Integer include_type = True ingredients = ItemAttributeRoute( fields.Array( fields.Object({ "ingredient": fields.String(), "amount": fields.String() })))
class DrinkResource(ModelResource): recipe = ItemAttributeRoute( fields.Array( fields.Object( properties={ "ingredient": fields.ToOne("ingredient"), "volume": fields.Number() }))) class Meta: name = "drink" model = name manager = MemoryManager id_field_class = fields.Integer include_type = True class Schema: name = fields.String()