{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "DesignTokenTemplateSchema",
  "description": "Schema Describing the structure of the Design Token template, to enhance a Design Token structure",
  "allOf": [
    {
      "$ref": "#/definitions/tokenTemplateGroup"
    }
  ],
  "definitions": {
    "otterExtensionMetadata": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "array",
          "description": "List of tags associated to the variable",
          "items": {
            "type": "string"
          }
        },
        "label": {
          "type": "string",
          "description": "Label of the variable, it will be used to display the variable name in the CMS if specified"
        },
        "category": {
          "type": "string",
          "description": "Category of the variable"
        },
        "component": {
          "type": "object",
          "description": "Component reference if the variable is linked to one",
          "properties": {
            "library": {
              "type": "string",
              "description": "Name of the library containing the component"
            },
            "name": {
              "type": "string",
              "description": "Name of the component"
            }
          },
          "required": [
            "library",
            "name"
          ],
          "additionalProperties": false
        }
      }
    },
    "otterExtension": {
      "type": "object",
      "properties": {
        "o3rPrivate": {
          "description": "Determine if the token is flagged as private",
          "type": "boolean",
          "default": false
        },
        "o3rImportant": {
          "description": "Determine if the token should be flagged as important when generated",
          "examples": [
            "Css Generation of `my-var` with `o3rImportant: true` will result to `:root { --my-var: #000 !important; }`"
          ],
          "type": "boolean",
          "default": false
        },
        "o3rScope": {
          "description": "Scope to apply to the generated variable",
          "examples": [
            "Css Generation of `my-var` with `o3rScope: 'html .my-class'` will result to `:root { html .my-class { --my-var: #000; } }`"
          ],
          "type": "string"
        },
        "o3rMetadata": {
          "description": "Additional information to provide to the metadata if generated. The metadata properties will be used only with the `o3r/<type>/metadata` formats.",
          "$ref": "#/definitions/otterExtensionMetadata"
        },
        "o3rUnit": {
          "description": "Convert a numeric value from the specified unit to the new unit. It will add a unit to the token with type \"number\" for which the unit is not specified.\nIn case of complex type (such as shadow, transition, etc...), the unit will be applied to all numeric types in it.",
          "type": "string"
        },
        "o3rRatio": {
          "description": "Ratio to apply to previous value. The ratio will be applied only on token with \"number\" type or on the first numbers determined in \"string\" like types.\nIn case of complex type (such as shadow, transition, etc...), the ratio will be applied to all numeric types in it.",
          "type": "number"
        },
        "o3rExpectOverride": {
          "description": "Indicate that the token is expected to be overridden by external rules. This is converted to the Style Dictionary themeable attribute",
          "type": "boolean",
          "default": false
        }
      }
    },
    "extensions": {
      "description": "Information to enhance generation",
      "allOf": [
        {
          "$ref": "#/definitions/otterExtension"
        }
      ]
    },
    "tokenTemplateGroup": {
      "type": "object",
      "properties": {
        "$schema": {
          "type": "string"
        },
        "$description": {
          "type": "string"
        },
        "$extensions": {
          "$ref": "#/definitions/extensions"
        }
      },
      "patternProperties": {
        "^[^$.].*$": {
          "$ref": "#/definitions/tokenTemplateGroup"
        }
      },
      "additionalProperties": false
    }
  }
}
