{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opengastronomy.org/schema/v0.2/cuisine.schema.json",
  "title": "OGS Cuisine",
  "description": "A culinary tradition or regional cuisine, identified by endonym-first naming and optional sub-cuisine hierarchy. See spec/ogs-i18n.md and spec/ogs-core.md.",
  "type": "object",
  "required": ["id", "ogs_version", "name", "primary_language"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ogs:[a-z0-9-]+:cuisine:[a-z0-9-]+$"
    },
    "ogs_version": {
      "type": "string",
      "pattern": "^0\\.2\\.\\d+$"
    },
    "primary_language": { "$ref": "#/$defs/bcp47_tag" },
    "available_languages": {
      "type": "array",
      "items": { "$ref": "#/$defs/bcp47_tag" }
    },
    "name": { "$ref": "#/$defs/lstring" },
    "description": { "$ref": "#/$defs/lstring" },
    "parent_cuisine": {
      "type": "string",
      "pattern": "^ogs:[a-z0-9-]+:cuisine:[a-z0-9-]+$",
      "description": "Parent cuisine reference for sub-cuisines (e.g. lyonnaise → french)."
    },
    "sub_cuisines": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^ogs:[a-z0-9-]+:cuisine:[a-z0-9-]+$"
      },
      "description": "Direct child cuisine references."
    },
    "iso_country_codes": {
      "type": "array",
      "items": { "type": "string", "pattern": "^[A-Z]{2}$" },
      "description": "ISO 3166-1 alpha-2 country codes most closely associated with this cuisine. Advisory; cuisines may span countries."
    },
    "iso_region_code": {
      "type": "string",
      "description": "Optional ISO 3166-2 subdivision code (e.g. IT-62 for Lazio) for sub-national cuisines."
    },
    "hallmark_ingredients": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^ogs:[a-z0-9-]+:ingredient:[a-z0-9-]+$"
      }
    },
    "hallmark_techniques": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Cooking methods (from the cooking-methods vocab) canonically associated with this cuisine."
    },
    "notes": { "$ref": "#/$defs/lstring" },
    "metadata": { "$ref": "#/$defs/metadata" }
  },
  "additionalProperties": true,
  "$defs": {
    "bcp47_tag": {
      "type": "string",
      "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
    },
    "lstring": {
      "oneOf": [
        { "type": "string", "minLength": 1 },
        {
          "type": "object",
          "minProperties": 1,
          "patternProperties": {
            "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$": { "type": "string", "minLength": 1 }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": ["labels"],
          "properties": {
            "primary_language": { "$ref": "#/$defs/bcp47_tag" },
            "labels": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "required": ["value", "language"],
                "properties": {
                  "value": { "type": "string", "minLength": 1 },
                  "language": { "$ref": "#/$defs/bcp47_tag" },
                  "script": { "type": "string", "pattern": "^[A-Z][a-z]{3}$" },
                  "role": {
                    "type": "string",
                    "enum": ["preferred", "alternate", "transliteration", "descriptive", "loan", "historical", "deprecated", "ipa"]
                  },
                  "transliteration_scheme": { "type": "string" },
                  "translation": { "type": "object", "additionalProperties": true }
                },
                "additionalProperties": false
              }
            }
          },
          "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
    }
  }
}
