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

FieldTypeRequiredDescriptionConstraints
itemsarray of stringyes
foodsarray of objectyes
foods[].slugstringyes
foods[].namestringyes
suggestionsobjectyes
suggestions.can_makearray of objectyes
suggestions.can_make[].slugstringyes
suggestions.can_make[].namestringyes
suggestions.can_make[].servesinteger
suggestions.can_make[].minutesinteger
suggestions.can_make[].missingarray of string
suggestions.almostarray of objectyes
suggestions.almost[].slugstringyes
suggestions.almost[].namestringyes
suggestions.almost[].servesinteger
suggestions.almost[].minutesinteger
suggestions.almost[].missingarray of string
notestring

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 }] }