{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedino.dev/schema/scan-result.v1.json",
  "title": "Dino ScanResultV1",
  "description": "Supported, versioned JSON result for `dino scan --format json` (contractVersion 1.0).",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "core", "meta"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "const": "1.0"
    },
    "core": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "operationCount",
        "health",
        "severityCounts",
        "coverage",
        "operations"
      ],
      "properties": {
        "title": { "type": "string" },
        "operationCount": { "type": "integer", "minimum": 0 },
        "health": {
          "type": "object",
          "additionalProperties": false,
          "required": ["score", "level", "verdict"],
          "properties": {
            "score": { "type": ["number", "null"] },
            "level": {
              "type": "string",
              "enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "CLEAN", "UNTESTED"]
            },
            "verdict": {
              "type": "string",
              "enum": ["Critical", "At risk", "Needs attention", "Healthy", "Untested"]
            }
          }
        },
        "severityCounts": {
          "type": "object",
          "additionalProperties": { "type": "number" }
        },
        "coverage": { "type": "string", "enum": ["full", "partial"] },
        "operations": {
          "type": "array",
          "items": { "$ref": "#/$defs/operation" }
        }
      }
    },
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": ["generatedAt", "introspectionLevel"],
      "properties": {
        "generatedAt": { "type": "string" },
        "runId": { "type": "string" },
        "durationMs": { "type": "number" },
        "toolVersion": { "type": "string" },
        "introspectionLevel": { "type": "string" },
        "partial": { "type": "boolean" },
        "reason": { "type": "string" }
      }
    }
  },
  "$defs": {
    "operation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "kind",
        "type",
        "module",
        "deprecated",
        "schemaDescription",
        "args",
        "returnType",
        "coverageStatus",
        "toolFindings",
        "healthScore",
        "tested"
      ],
      "properties": {
        "name": { "type": "string" },
        "kind": { "type": "string", "enum": ["operation", "type-field"] },
        "type": {
          "type": "string",
          "enum": ["query", "mutation", "subscription", "rest"]
        },
        "module": { "type": "string" },
        "deprecated": { "type": "boolean" },
        "schemaDescription": { "type": ["string", "null"] },
        "args": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "type", "isRequired"],
            "properties": {
              "name": { "type": "string" },
              "type": { "type": "string" },
              "isRequired": { "type": "boolean" }
            }
          }
        },
        "returnType": { "type": "string" },
        "coverageStatus": {
          "type": "string",
          "enum": ["documented-and-tested", "documented-only", "absent"]
        },
        "toolFindings": {
          "type": "object",
          "additionalProperties": false,
          "required": ["toolsRun", "worstSeverity", "byTool"],
          "properties": {
            "toolsRun": { "type": "array", "items": { "type": "string" } },
            "worstSeverity": {
              "type": "string",
              "enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "CLEAN", "UNTESTED"]
            },
            "byTool": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": false,
                "required": ["severity", "findingCount", "examples"],
                "properties": {
                  "severity": {
                    "type": "string",
                    "enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW", "CLEAN", "UNTESTED"]
                  },
                  "findingCount": { "type": "number" },
                  "examples": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "healthScore": { "type": ["number", "null"] },
        "tested": { "type": "boolean" },
        "parameters": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "in"],
            "properties": {
              "name": { "type": "string" },
              "in": {
                "type": "string",
                "enum": ["path", "query", "header", "cookie"]
              },
              "required": { "type": "boolean" }
            }
          }
        }
      }
    }
  }
}
