{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apigenie.pl/schemas/apigenie-test-report.json",
  "title": "apigenie test --report",
  "description": "The report of `apigenie test --report FILE`. When the run checked a spec, it also carries the members of the contract report (apigenie-contract-report.json): spec, validation, summary, violations... Adding members keeps formatVersion; removing a member or changing its meaning or type increments it.",
  "type": "object",
  "required": ["report", "formatVersion", "tests", "requests"],
  "properties": {
    "report": { "const": "apigenie-test" },
    "formatVersion": {
      "description": "The version of this format.",
      "const": 1
    },
    "version": {
      "description": "The former name of formatVersion, removed in the next release.",
      "const": 1,
      "deprecated": true
    },
    "tests": {
      "type": "object",
      "required": ["total", "passed", "failed", "skipped", "gate"],
      "properties": {
        "total": { "type": "integer", "minimum": 0 },
        "passed": { "type": "integer", "minimum": 0 },
        "failed": { "type": "integer", "minimum": 0 },
        "skipped": { "type": "integer", "minimum": 0 },
        "gate": { "$ref": "https://apigenie.pl/schemas/apigenie-contract-report.json#/$defs/gate" }
      }
    },
    "requests": {
      "description": "One item per request of the .http files, in run order.",
      "type": "array",
      "items": { "$ref": "#/$defs/request" }
    }
  },
  "if": { "required": ["summary"] },
  "then": { "$ref": "https://apigenie.pl/schemas/apigenie-contract-report.json" },
  "$defs": {
    "request": {
      "type": "object",
      "required": ["name", "file", "line", "method", "url", "durationMs", "outcome", "failures", "assertions", "violations"],
      "properties": {
        "name": { "type": "string" },
        "file": { "type": "string" },
        "line": { "type": "integer", "minimum": 0 },
        "method": { "type": "string" },
        "url": { "type": "string" },
        "status": { "description": "The HTTP status of the response.", "type": "integer" },
        "grpc": { "const": true },
        "grpcStatus": { "type": "string" },
        "durationMs": { "type": "integer", "minimum": 0 },
        "operationId": { "type": "string" },
        "path": { "description": "The path template of the matched operation.", "type": "string" },
        "channel": { "type": "string" },
        "address": { "type": "string" },
        "messagesSent": { "type": "integer", "minimum": 0 },
        "messagesReceived": { "type": "integer", "minimum": 0 },
        "outcome": { "type": "string", "examples": ["passed", "failed", "skipped"] },
        "validationSkipped": { "const": true },
        "skipped": { "description": "Why the request was skipped.", "type": "string" },
        "failures": { "type": "array", "items": { "type": "string" } },
        "assertions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "passed"],
            "properties": {
              "name": { "type": "string" },
              "passed": { "type": "boolean" },
              "message": { "type": "string" }
            }
          }
        },
        "violations": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["check", "code", "severity", "location", "message"],
            "properties": {
              "check": { "type": "string" },
              "code": { "type": "string" },
              "severity": { "enum": ["error", "warn", "info"] },
              "location": { "type": "string" },
              "message": { "type": "string" }
            }
          }
        },
        "logs": { "type": "array", "items": { "type": "string" } },
        "notes": { "type": "array", "items": { "type": "string" } }
      }
    }
  }
}
