{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apigenie.pl/schemas/apigenie-changelog-report.json",
  "title": "apigenie changelog --formatter json",
  "description": "The changelog of a spec's Git history, as `apigenie changelog --formatter json` writes it: by revision (the default) or by operation (`--by operation`; by method for Protobuf). Adding members keeps formatVersion; removing a member or changing its meaning or type increments it.",
  "type": "object",
  "required": ["formatVersion", "spec"],
  "properties": {
    "formatVersion": {
      "description": "The version of this format.",
      "const": 1
    },
    "spec": {
      "description": "The path of the spec in the repository.",
      "type": "string"
    },
    "entries": {
      "description": "Revisions view: one entry per revision that changed the spec, newest first.",
      "type": "array",
      "items": { "$ref": "#/$defs/entry" }
    },
    "operations": {
      "description": "Operations view (OpenAPI, Swagger, AsyncAPI, GraphQL): the history of each operation.",
      "type": "array",
      "items": { "$ref": "#/$defs/history" }
    },
    "methods": {
      "description": "Operations view (Protobuf): the history of each RPC method.",
      "type": "array",
      "items": { "$ref": "#/$defs/history" }
    },
    "warnings": {
      "description": "Revisions that could not be read, and similar problems.",
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "oneOf": [
    { "title": "revisions", "required": ["entries"] },
    { "title": "operations", "required": ["operations"] },
    { "title": "methods", "required": ["methods"] }
  ],
  "$defs": {
    "severity": {
      "enum": ["none", "non-functional", "non-breaking", "breaking"]
    },
    "revision": {
      "type": "object",
      "required": ["id", "shortId", "label", "author", "date", "subject"],
      "properties": {
        "id": { "description": "The commit hash.", "type": "string" },
        "shortId": { "type": "string" },
        "label": { "description": "The tag, or the short hash.", "type": "string" },
        "tag": { "type": "string" },
        "unreleased": { "description": "The working tree, not a commit.", "const": true },
        "author": { "type": "string" },
        "date": { "type": "string" },
        "subject": { "type": "string" }
      }
    },
    "change": {
      "type": "object",
      "required": ["description", "severity"],
      "properties": {
        "description": { "type": "string" },
        "severity": { "$ref": "#/$defs/severity" }
      }
    },
    "entry": {
      "type": "object",
      "required": ["revision", "initial", "severity"],
      "properties": {
        "revision": { "$ref": "#/$defs/revision" },
        "previous": { "$ref": "#/$defs/revision" },
        "previousVersion": { "type": "string" },
        "initial": { "description": "The first revision of the spec.", "type": "boolean" },
        "version": { "description": "The version of the spec in this revision.", "type": "string" },
        "severity": { "$ref": "#/$defs/severity" },
        "metadata": { "type": "array", "items": { "type": "string" } }
      }
    },
    "history": {
      "type": "object",
      "required": ["history"],
      "properties": {
        "history": {
          "description": "The changes of the operation, newest first; each item carries the revision's members and the change.",
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "change", "severity"],
            "properties": {
              "id": { "type": "string" },
              "change": { "description": "added, modified, deprecated or removed.", "type": "string" },
              "severity": { "$ref": "#/$defs/severity" },
              "details": { "type": "array", "items": { "type": "string" } },
              "changes": { "type": "array", "items": { "$ref": "#/$defs/change" } }
            }
          }
        }
      }
    }
  }
}
