{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://spec.soustack.org/stacks/dietary.schema.json",
  "title": "Dietary Stack",
  "type": "object",
  "properties": {
    "dietary": {
      "type": "object",
      "properties": {
        "basis": { "type": "string", "enum": ["perServing", "perRecipe"] },
        "calories": { "type": "number", "minimum": 0 },
        "macros": {
          "type": "object",
          "properties": {
            "protein": { "type": "number", "minimum": 0 },
            "fat": { "type": "number", "minimum": 0 },
            "carbohydrates": { "type": "number", "minimum": 0 },
            "metadata": { "type": "object", "additionalProperties": true }
          },
          "minProperties": 1,
          "additionalProperties": false,
          "patternProperties": {
            "^x-": { "$ref": "../defs/common.schema.json#/properties/extensionLaneValue" }
          }
        },
        "diets": { "type": "array", "items": { "type": "string" } },
        "allergens": { "type": "array", "items": { "type": "string" } },
        "metadata": { "type": "object", "additionalProperties": true }
      },
      "required": ["basis"],
      "additionalProperties": false,
      "anyOf": [
        { "required": ["calories"] },
        { "required": ["macros"] },
        { "required": ["diets"] },
        { "required": ["allergens"] }
      ],
      "patternProperties": {
        "^x-": { "$ref": "../defs/common.schema.json#/properties/extensionLaneValue" }
      }
    }
  },
  "required": ["dietary"],
  "additionalProperties": false
}
