{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "message": { "type": "string", "minLength": 1 },
    "types": { "$ref": "#/$defs/types" },
    "level": { 
      "type": "string",
      "enum": ["error", "warning", "info"],
      "default": "error"
    },
    "position": { "$ref": "#/$defs/position" }
  },
  "$defs": {
    "errors": { 
      "type": "array",
      "items": { "$ref": "#" }
    },
    "types": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "position": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/locator" 
          }
        },
        { "$ref": "#/$defs/namedMap" }
      ]
    },
    "locator": {
      "type": "object",
      "allOf": [
        {
          "properties": {
            "dimension": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9]*$"
            },
            "address": { "type": "string" },
            "value": { "$ref": "#/$defs/namedMap" }
          }
        }, {
          "oneOf": [
            {
              "properties": {
                "errors": { "$ref": "#/$defs/errors" }
              },
              "properties": {
                "reports": { 
                  "type": "array",
                  "items": { "$ref": "#/$defs/report" }
                }
              }
            }
          ]
        } ],
      "required": ["dimension", "address"]
    },
    "positions": { 
      "type": "array",
      "items": { 
        "anyOf": [
          { "$ref": "#/$defs/position" },
          { "const": null }
        ]
      }
    },
    "namedMap": {
      "type": "object",
      "patternProperties": {
        "^[a-z][a-z0-9]*$": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "report": {
      "type": "object",
      "properties": {
        "types": { "$ref": "#/$defs/types" },
        "errors": { 
          "type": "array",
          "items": {
            "anyOf": [
              { "$ref": "#" },
              { "const": null }
            ]
          }
        },
        "compliances": { "$ref": "#/$defs/positions" },
        "skipped": { "$ref": "#/$defs/positions" },
        "totalErrors": { "type": "integer", "minimum": 0 },
        "totalCompliances": { "type": "integer", "minimum": 0 },
        "totalSkipped": { "type": "integer", "minimum": 0 },
        "totalFindings": { "type": "integer", "minimum": 0 },
        "partial": { "oneOf": [
          { "type": "boolean" },
          { "type": "array", "items": { "$ref": "#" } }
        ] },
        "duration": { "type": "number", "minimum": 0 }
      },
      "required": ["errors"]
    }
  }
}
