{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://benchmarks.komodor.com/schema/benchmark.schema.json",
  "title": "Benchmark frontmatter",
  "type": "object",
  "required": ["title", "description", "benchmark"],
  "properties": {
    "title": { "type": "string", "minLength": 3 },
    "description": { "type": "string", "minLength": 50, "maxLength": 200 },
    "benchmark": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "status", "primaryMetric", "metrics", "published"],
      "properties": {
        "version": { "type": "string" },
        "status": { "enum": ["published", "preview", "demo"] },
        "published": { "type": "string", "format": "date" },
        "tags": { "type": "array", "items": { "type": "string" } },
        "primaryMetric": { "type": "string" },
        "source": { "type": "string", "format": "uri", "pattern": "^https?://" },
        "metrics": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["key", "label", "higherIsBetter"],
            "properties": {
              "key": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
              "label": { "type": "string" },
              "description": { "type": "string" },
              "unit": { "enum": ["%", "$", "s", "ms", "tokens", ""] },
              "precision": { "type": "integer", "minimum": 0, "maximum": 6 },
              "higherIsBetter": { "type": "boolean" }
            }
          }
        },
        "charts": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["type", "metric"],
                "properties": { "type": { "const": "bar" }, "metric": { "type": "string" }, "title": { "type": "string" } }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["type", "x", "y"],
                "properties": {
                  "type": { "const": "scatter" },
                  "x": { "type": "string" },
                  "y": { "type": "string" },
                  "title": { "type": "string" }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["type"],
                "properties": {
                  "type": { "const": "radar" },
                  "top": { "type": "integer", "minimum": 2, "maximum": 8 },
                  "title": { "type": "string" }
                }
              }
            ]
          }
        }
      }
    }
  }
}
