{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://blackshard.com.au/open-data/tools/schema/essential-eight-self-score.schema.json",
  "title": "Essential Eight self-score question set",
  "description": "The question set behind https://blackshard.com.au/tools/essential-eight-check: one owner's question per strategy per maturity level of the ASD Essential Eight maturity model, each naming the requirements it summarises, and every requirement of the model with the levels it belongs to. Published under CC BY 4.0; the model wording is the Australian Signals Directorate's under CC BY 4.0.",
  "type": "object",
  "required": ["title", "description", "version", "modelEdition", "licence", "licenceUrl", "attribution", "source", "tool", "levels", "rule", "strategies"],
  "additionalProperties": false,
  "properties": {
    "title": { "type": "string", "minLength": 1 },
    "description": { "type": "string", "minLength": 1 },
    "version": { "type": "integer", "minimum": 1 },
    "modelEdition": { "type": "string", "minLength": 1 },
    "licence": { "const": "CC BY 4.0" },
    "licenceUrl": { "const": "https://creativecommons.org/licenses/by/4.0/" },
    "attribution": { "type": "string", "minLength": 1 },
    "source": { "$ref": "#/$defs/source" },
    "tool": { "type": "string", "pattern": "^https://blackshard\\.com\\.au/tools/[a-z0-9-]+$" },
    "levels": {
      "type": "object",
      "required": ["1", "2", "3"],
      "additionalProperties": false,
      "properties": { "1": { "type": "string" }, "2": { "type": "string" }, "3": { "type": "string" } }
    },
    "rule": { "type": "string", "minLength": 1 },
    "strategies": { "type": "array", "minItems": 8, "items": { "$ref": "#/$defs/strategy" } }
  },
  "$defs": {
    "source": {
      "type": "object",
      "required": ["publisher", "title", "url", "retrieved", "licence", "licenceUrl", "attribution"],
      "additionalProperties": false,
      "properties": {
        "publisher": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "pattern": "^https://" },
        "retrieved": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
        "licence": { "type": "string", "minLength": 1 },
        "licenceUrl": { "type": "string", "pattern": "^https://" },
        "attribution": { "type": "string", "minLength": 1 }
      }
    },
    "strategy": {
      "type": "object",
      "required": ["code", "name", "line", "questions", "requirements"],
      "additionalProperties": false,
      "properties": {
        "code": { "type": "string", "pattern": "^[a-z]{2,4}$" },
        "name": { "type": "string", "minLength": 1 },
        "line": { "type": "string", "minLength": 1 },
        "questions": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/question" } },
        "requirements": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/requirement" } }
      }
    },
    "question": {
      "type": "object",
      "required": ["id", "level", "ask", "requirements"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z]{2,4}:[123]$" },
        "level": { "enum": [1, 2, 3] },
        "ask": { "type": "string", "pattern": "\\?$" },
        "requirements": { "type": "array", "minItems": 1, "items": { "type": "string", "pattern": "^[a-z]{2,4}-\\d{2}$" } }
      }
    },
    "requirement": {
      "type": "object",
      "required": ["id", "levels", "asd"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z]{2,4}-\\d{2}$" },
        "levels": { "type": "array", "minItems": 1, "items": { "enum": [1, 2, 3] } },
        "asd": { "type": "string", "minLength": 10 }
      }
    }
  }
}
