{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apigenie.pl/schemas/apigenie-diff-report.json",
  "title": "apigenie diff --formatter json",
  "description": "The report of `apigenie diff --formatter json`: `--report status`, `--report changelog` or `--report detailed`, for OpenAPI, Swagger, AsyncAPI, GraphQL and Protobuf. Adding members keeps formatVersion; removing a member or changing its meaning or type increments it.",
  "type": "object",
  "required": ["formatVersion"],
  "properties": {
    "formatVersion": {
      "description": "The version of this format.",
      "const": 1
    },
    "status": {
      "description": "The highest severity of the changes.",
      "$ref": "#/$defs/severity"
    },
    "changes": {
      "description": "--report detailed: every change, in document order.",
      "type": "array",
      "items": { "$ref": "#/$defs/change" }
    },
    "metadata": {
      "description": "--report changelog: which top-level fields (title, description, contact...) changed.",
      "type": "object",
      "additionalProperties": { "type": "boolean" }
    }
  },
  "anyOf": [
    {
      "title": "status",
      "required": ["status"]
    },
    {
      "title": "detailed",
      "required": ["changes"]
    },
    {
      "title": "changelog",
      "description": "Groups of added, modified and removed items, named after the elements of the format: operations (OpenAPI, Swagger, AsyncAPI), channels and servers (AsyncAPI), types, directives... (GraphQL), services, messages... (Protobuf).",
      "required": ["metadata"]
    }
  ],
  "$defs": {
    "severity": {
      "enum": ["none", "non-functional", "non-breaking", "breaking"]
    },
    "change": {
      "type": "object",
      "required": ["type", "severity", "target"],
      "properties": {
        "type": { "description": "What happened, such as key_added, key_removed, property_modified or element_added.", "type": "string" },
        "severity": { "$ref": "#/$defs/severity" },
        "target": { "description": "The kind of element that changed.", "type": "string" },
        "config_key": { "description": "The diff configuration key that rates this change.", "type": "string" },
        "key": { "description": "The name of the changed element in its parent.", "type": "string" },
        "index": { "description": "The position of the changed element in its parent list.", "type": "integer", "minimum": 0 },
        "description": { "type": "string" },
        "nested": { "type": "integer", "minimum": 0 },
        "line": { "description": "1-based line in the new document; a removal is reported at the closest enclosing element that is still there.", "type": "integer" },
        "column": { "type": "integer" }
      }
    }
  }
}
