Using the example below, how can I restrict the "contents" of a recipe to only be one or multiple instances of the following:
{
"quantity": "4",
"unit": "slices",
"ingredient": "bacon"
}
Example JSON
{
"name": "Big Breakfast",
"note": "Something to eat every friday",
"star": true,
"contents": [
{
"quantity": "4",
"unit": "slices",
"ingredient": "bacon"
},
{
"quantity": "2",
"unit": "",
"ingredient": "eggs"
},
{
"quantity": "2",
"unit": "slices",
"ingredient": "cheese"
}
]
}
Schema
class RecipeBase(BaseModel):
name: str
note: Optional[str]
star: Optional[bool] = False
contents: Optional[List[dict]] = []
class Config:
orm_mode = True