{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengastronomy.org/schema/v0.5/dish.schema.json",
  "title": "OGS Dish",
  "description": "A composed dish with components, cooking methods, and overall sensory profile. See spec/ogs-comp.md.",
  "type": "object",
  "required": [
    "id",
    "ogs_version",
    "name",
    "components",
    "overall_sensory_profile"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ogs:[a-z0-9-]+:dish:[a-z0-9-]+$",
      "description": "OGS identifier: ogs:<namespace>:dish:<id>."
    },
    "ogs_version": {
      "$ref": "common.schema.json#/$defs/ogs_version"
    },
    "primary_language": {
      "$ref": "common.schema.json#/$defs/primary_language"
    },
    "available_languages": {
      "$ref": "common.schema.json#/$defs/available_languages"
    },
    "name": {
      "$ref": "common.schema.json#/$defs/lstring",
      "description": "Human-readable dish name."
    },
    "description": {
      "$ref": "common.schema.json#/$defs/lstring",
      "description": "Longer description of the dish."
    },
    "cuisine": {
      "type": "string",
      "minLength": 1,
      "description": "Cuisine reference (ogs:<namespace>:cuisine:<id>). Free text is accepted for v0.1 compatibility but does not meet L2."
    },
    "course": {
      "type": "string",
      "enum": [
        "amuse",
        "appetizer",
        "soup",
        "salad",
        "fish",
        "main",
        "side",
        "cheese",
        "pre_dessert",
        "dessert",
        "petit_four",
        "snack",
        "breakfast"
      ],
      "description": "Course position in a meal (vocab/courses.json)."
    },
    "service_temperature": {
      "type": "string",
      "enum": [
        "frozen",
        "cold",
        "cool",
        "room",
        "warm",
        "hot",
        "very_hot"
      ],
      "description": "Intended serving temperature."
    },
    "serve_temperature_c": {
      "$ref": "common.schema.json#/$defs/temperature_range_c",
      "description": "Serving temperature range in °C (new in v0.5); more precise than service_temperature."
    },
    "components": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/component"
      },
      "description": "Dish components with roles and cooking methods. See spec/ogs-comp.md §6."
    },
    "overall_sensory_profile": {
      "$ref": "common.schema.json#/$defs/sensory_profile",
      "description": "Sensory profile of the finished dish."
    },
    "notes": {
      "$ref": "common.schema.json#/$defs/lstring"
    },
    "dietary": {
      "$ref": "common.schema.json#/$defs/dietary"
    },
    "metadata": {
      "$ref": "common.schema.json#/$defs/metadata"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "component": {
      "type": "object",
      "required": [
        "role"
      ],
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "main_protein",
            "main_vegetable",
            "starch",
            "sauce",
            "fat_component",
            "acid_component",
            "aromatic_garnish",
            "seasoning",
            "textural_element"
          ],
          "description": "Component role (vocab/component_roles.json)."
        },
        "ingredient_ref": {
          "type": "string",
          "pattern": "^ogs:[a-z0-9-]+:ingredient:[a-z0-9-]+$",
          "description": "Reference to an OGS ingredient."
        },
        "preparation_ref": {
          "type": "string",
          "pattern": "^ogs:[a-z0-9-]+:dish:[a-z0-9-]+$",
          "description": "Reference to another dish document used as a sub-preparation, such as a sauce or stock (new in v0.5). A component has either ingredient_ref or preparation_ref."
        },
        "cooking_method": {
          "type": "string",
          "enum": [
            "raw",
            "seared",
            "grilled",
            "roasted",
            "braised",
            "poached",
            "steamed",
            "fried",
            "confit",
            "smoked",
            "fermented",
            "cured",
            "pickled",
            "dehydrated",
            "sous_vide",
            "blanched",
            "sauteed",
            "baked",
            "charred",
            "emulsified",
            "boiled",
            "simmered",
            "stewed",
            "pan_fried",
            "stir_fried",
            "marinated",
            "dry_aged",
            "toasted",
            "caramelized",
            "flambeed",
            "reduced",
            "pressure_cooked",
            "slow_cooked"
          ],
          "description": "Cooking method (vocab/cooking_methods.json)."
        },
        "maillard_index": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5,
          "description": "Degree of browning, 0-5. See spec/ogs-comp.md §4."
        },
        "reduction_level": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5,
          "description": "Concentration of liquids, 0-5. See spec/ogs-comp.md §5."
        },
        "proportion": {
          "type": "string",
          "enum": [
            "dominant",
            "significant",
            "accent",
            "trace"
          ],
          "description": "Relative share of the dish. See spec/ogs-comp.md §6.2."
        },
        "share": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Approximate share of the dish by weight, 0–1 (new in v0.5)."
        },
        "sensory_contribution": {
          "$ref": "common.schema.json#/$defs/sensory_profile",
          "description": "Partial sensory profile describing this component's contribution."
        }
      },
      "additionalProperties": true,
      "oneOf": [
        {
          "required": [
            "ingredient_ref"
          ],
          "not": {
            "required": [
              "preparation_ref"
            ]
          }
        },
        {
          "required": [
            "preparation_ref"
          ],
          "not": {
            "required": [
              "ingredient_ref"
            ]
          }
        }
      ]
    }
  }
}
