{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengastronomy.org/schema/v0.1/dish.schema.json",
  "title": "OGS Dish",
  "description": "A composed dish with components, cooking methods, and overall sensory profile.",
  "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 in the format ogs:<namespace>:dish:<id>"
    },
    "ogs_version": {
      "type": "string",
      "const": "0.1.0",
      "description": "OGS specification version"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Human-readable dish name"
    },
    "description": {
      "type": "string",
      "description": "Longer description of the dish"
    },
    "cuisine": {
      "type": "string",
      "description": "Cuisine tradition (e.g., french, japanese, italian)"
    },
    "course": {
      "type": "string",
      "enum": ["amuse", "appetizer", "soup", "salad", "fish", "main", "cheese", "dessert", "petit_four"],
      "description": "Course position in a meal"
    },
    "service_temperature": {
      "type": "string",
      "enum": ["frozen", "cold", "cool", "room", "warm", "hot", "very_hot"],
      "description": "Intended serving temperature"
    },
    "components": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/component"
      },
      "description": "Array of dish components with roles and cooking methods"
    },
    "overall_sensory_profile": {
      "$ref": "#/$defs/sensory_profile",
      "description": "Complete sensory profile of the finished dish"
    },
    "notes": {
      "type": "string",
      "description": "Additional notes about the dish"
    },
    "metadata": {
      "$ref": "#/$defs/metadata"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "component": {
      "type": "object",
      "required": ["role", "ingredient_ref"],
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "main_protein", "main_vegetable", "starch", "sauce",
            "fat_component", "acid_component", "aromatic_garnish",
            "seasoning", "textural_element"
          ]
        },
        "ingredient_ref": {
          "type": "string",
          "pattern": "^ogs:[a-z0-9-]+:ingredient:[a-z0-9-]+$",
          "description": "Reference to an OGS ingredient entity"
        },
        "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"
          ]
        },
        "maillard_index": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5,
          "description": "Degree of browning, 0-5 scale"
        },
        "reduction_level": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5,
          "description": "Concentration level for liquids, 0-5 scale"
        },
        "proportion": {
          "type": "string",
          "enum": ["dominant", "significant", "accent", "trace"]
        },
        "sensory_contribution": {
          "type": "object",
          "description": "Partial sensory profile of this component's contribution",
          "properties": {
            "basic_tastes": {
              "$ref": "#/$defs/basic_tastes"
            },
            "aromatics": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/aromatic_entry"
              }
            },
            "texture": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "sensory_profile": {
      "type": "object",
      "properties": {
        "basic_tastes": {
          "$ref": "#/$defs/basic_tastes"
        },
        "structural": {
          "$ref": "#/$defs/structural"
        },
        "aromatics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/aromatic_entry"
          }
        },
        "texture": {
          "type": "array",
          "items": { "type": "string" }
        },
        "finish_length": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        },
        "complexity": {
          "type": "number",
          "minimum": 0,
          "maximum": 10
        }
      },
      "additionalProperties": true
    },
    "basic_tastes": {
      "type": "object",
      "properties": {
        "sweet": { "$ref": "#/$defs/intensity_value" },
        "sour": { "$ref": "#/$defs/intensity_value" },
        "salty": { "$ref": "#/$defs/intensity_value" },
        "bitter": { "$ref": "#/$defs/intensity_value" },
        "umami": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "structural": {
      "type": "object",
      "properties": {
        "body": { "$ref": "#/$defs/intensity_value" },
        "acidity_perception": { "$ref": "#/$defs/intensity_value" },
        "tannin": { "$ref": "#/$defs/intensity_value" },
        "astringency": { "$ref": "#/$defs/intensity_value" },
        "alcohol_heat": { "$ref": "#/$defs/intensity_value" },
        "effervescence": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "intensity_value": {
      "type": "number",
      "minimum": 0,
      "maximum": 10
    },
    "aromatic_entry": {
      "type": "object",
      "required": ["family", "group", "item", "intensity"],
      "properties": {
        "family": {
          "type": "string",
          "enum": [
            "fruit", "floral", "herbal", "spice", "earth", "wood",
            "dairy", "savory", "confection", "vegetal", "marine"
          ]
        },
        "group": { "type": "string" },
        "item": { "type": "string" },
        "qualifier": {
          "type": "string",
          "enum": ["fresh", "dried", "cooked", "candied", "fermented", "zest", "overripe"]
        },
        "intensity": { "$ref": "#/$defs/intensity_value" }
      },
      "additionalProperties": false
    },
    "metadata": {
      "type": "object",
      "properties": {
        "created": { "type": "string", "format": "date-time" },
        "updated": { "type": "string", "format": "date-time" },
        "source": { "type": "string" },
        "license": { "type": "string" }
      },
      "additionalProperties": true
    }
  }
}
