{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://huecodex.com/json/hue-codex-plain-report.schema.json",
  "title": "Hue Codex plain report schema",
  "description": "Permissive schema for tool-specific Hue Codex report payloads and reference-list arrays. Token-style marker fields are excluded so malformed token exports cannot pass as generic plain reports.",
  "anyOf": [
    { "$ref": "#/$defs/plainReportObject" },
    { "$ref": "#/$defs/plainReportArray" }
  ],
  "$defs": {
    "plainReportObject": {
      "type": "object",
      "description": "Tool-specific Hue Codex report payload. There is no required cross-tool envelope.",
      "not": { "$ref": "#/$defs/tokenStyleDiscriminator" },
      "additionalProperties": { "$ref": "#/$defs/jsonValue" }
    },
    "plainReportArray": {
      "type": "array",
      "description": "Reference-list exports such as glossary or named-color data can use an array of records.",
      "items": {
        "type": "object",
        "additionalProperties": { "$ref": "#/$defs/jsonValue" }
      }
    },
    "tokenStyleDiscriminator": {
      "type": "object",
      "description": "Marker fields that route an object away from the generic plain-report schema.",
      "anyOf": [
        { "required": ["$schema"] },
        { "required": ["$extensions"] },
        { "required": ["dimension"] },
        {
          "required": ["color"],
          "properties": {
            "color": { "type": "object" }
          }
        }
      ]
    },
    "jsonValue": {
      "oneOf": [
        { "type": "string" },
        { "type": "number" },
        { "type": "integer" },
        { "type": "boolean" },
        { "type": "null" },
        {
          "type": "array",
          "items": { "$ref": "#/$defs/jsonValue" }
        },
        {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/jsonValue" }
        }
      ]
    }
  }
}
