{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ValidationSummary",
  "description": "Validation summary with collected issues",
  "type": "object",
  "properties": {
    "checks": {
      "$ref": "#/$defs/CheckResults"
    },
    "dialect": {
      "type": "string"
    },
    "issues": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ValidationIssue"
      }
    },
    "summary": {
      "$ref": "#/$defs/SummaryStats"
    }
  },
  "required": ["dialect", "issues", "summary", "checks"],
  "$defs": {
    "CheckResults": {
      "type": "object",
      "properties": {
        "ddl_dml_consistency": {
          "$ref": "#/$defs/CheckStatus"
        },
        "encoding": {
          "$ref": "#/$defs/CheckStatus"
        },
        "fk_integrity": {
          "$ref": "#/$defs/CheckStatus"
        },
        "pk_duplicates": {
          "$ref": "#/$defs/CheckStatus"
        },
        "syntax": {
          "$ref": "#/$defs/CheckStatus"
        }
      },
      "required": [
        "syntax",
        "encoding",
        "ddl_dml_consistency",
        "pk_duplicates",
        "fk_integrity"
      ]
    },
    "CheckStatus": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["ok"]
        },
        {
          "type": "object",
          "properties": {
            "failed": {
              "type": "integer",
              "minimum": 0
            }
          },
          "additionalProperties": false,
          "required": ["failed"]
        },
        {
          "type": "object",
          "properties": {
            "skipped": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": ["skipped"]
        }
      ]
    },
    "Location": {
      "description": "Location in the SQL dump where an issue was found",
      "type": "object",
      "properties": {
        "approx_line": {
          "type": ["integer", "null"],
          "minimum": 0
        },
        "statement_index": {
          "type": ["integer", "null"],
          "minimum": 0
        },
        "table": {
          "type": ["string", "null"]
        }
      }
    },
    "Severity": {
      "description": "Issue severity level",
      "type": "string",
      "enum": ["error", "warning", "info"]
    },
    "SummaryStats": {
      "type": "object",
      "properties": {
        "errors": {
          "type": "integer",
          "minimum": 0
        },
        "info": {
          "type": "integer",
          "minimum": 0
        },
        "statements_scanned": {
          "type": "integer",
          "minimum": 0
        },
        "tables_scanned": {
          "type": "integer",
          "minimum": 0
        },
        "warnings": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "errors",
        "warnings",
        "info",
        "tables_scanned",
        "statements_scanned"
      ]
    },
    "ValidationIssue": {
      "description": "A validation issue found in the SQL dump",
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "location": {
          "anyOf": [
            {
              "$ref": "#/$defs/Location"
            },
            {
              "type": "null"
            }
          ]
        },
        "message": {
          "type": "string"
        },
        "severity": {
          "$ref": "#/$defs/Severity"
        }
      },
      "required": ["code", "severity", "message"]
    }
  }
}
