예제 #1
0
        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()
                    })))
예제 #2
0
        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()