{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://okham.org/schemas/olr/0.2.0/schema.json",
  "title": "OKHAM catalogue OLR profile",
  "description": "Unpublished 0.2.0 draft edition derived from the current OKHAM current catalogue ruleset profile. See the specification for semantic checks and coverage limits.",
  "type": "object",
  "required": [
    "rulesetId",
    "version",
    "metadata",
    "rules"
  ],
  "properties": {
    "rulesetId": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9]*){3,}$"
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$"
    },
    "description": {
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "required": [
        "namespace"
      ],
      "properties": {
        "namespace": {
          "type": "string",
          "pattern": "^okham\\.[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9]*)*$"
        }
      }
    },
    "rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/rule"
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "rule": {
      "type": "object",
      "required": [
        "ruleId",
        "severity",
        "scope",
        "selector",
        "assert",
        "params",
        "message"
      ],
      "properties": {
        "ruleId": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]*(?:\\.[a-z][a-z0-9_-]*){3,}$"
        },
        "severity": {
          "enum": [
            "error",
            "warn",
            "info"
          ]
        },
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "selector": {
          "type": "object",
          "required": [
            "documentKind",
            "globs"
          ],
          "properties": {
            "documentKind": {
              "type": "string",
              "minLength": 1
            },
            "globs": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "additionalProperties": true
        },
        "assert": {
          "type": "string",
          "minLength": 1
        },
        "params": {
          "type": "object"
        },
        "message": {
          "type": "string",
          "minLength": 1
        },
        "suggestedFix": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  }
}
