FoodPantryResult food.pantry-result@1
Generated at from
openvibe-contracts v0.127.0 and
openvibe-sdk v0.37.0.
- Version
- 1.0.0
- Owner
- food
- Visibility
- public
- Status
- active
- Compatibility
- backward
- Schema
https://openvibe.network/contracts/food/pantry-result.v1.json
food.pantry-result@1: GET and PUT /api/v1/pantry on OpenVibe.Food: the slugs, each food as the food list shows it, and the suggestions matched against them (can_make: everything there; almost: one or two items missing, named).
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
items | array of string | yes | ||
foods | array of object | yes | ||
foods[].slug | string | yes | ||
foods[].name | string | yes | ||
suggestions | object | yes | ||
suggestions.can_make | array of object | yes | ||
suggestions.can_make[].slug | string | yes | ||
suggestions.can_make[].name | string | yes | ||
suggestions.can_make[].serves | integer | |||
suggestions.can_make[].minutes | integer | |||
suggestions.can_make[].missing | array of string | |||
suggestions.almost | array of object | yes | ||
suggestions.almost[].slug | string | yes | ||
suggestions.almost[].name | string | yes | ||
suggestions.almost[].serves | integer | |||
suggestions.almost[].minutes | integer | |||
suggestions.almost[].missing | array of string | |||
note | string |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: one
{
"items": [
"eggs-dozen"
],
"foods": [
{
"slug": "eggs-dozen",
"name": "Eggs, dozen"
}
],
"suggestions": {
"can_make": [],
"almost": [
{
"slug": "egg-fried-rice",
"name": "Egg fried rice",
"serves": 2,
"minutes": 15,
"missing": [
"Rice"
]
}
]
},
"note": "Basic suggestions."
}Rejected: no-suggestions
{
"items": [],
"foods": []
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('food.pantry-result@1', value); // { valid, errors: [{ path, message }] }