{
  "$id": "https://spec.openapis.org/overlay/1.2/schema/2026-08-08",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "The description of Overlay v1.2.x documents",
  "type": "object",
  "properties": {
    "overlay": {
      "type": "string",
      "pattern": "^1\\.2\\.\\d+$"
    },
    "$self": {
      "type": "string",
      "format": "uri-reference",
      "$comment": "MUST NOT contain a fragment",
      "pattern": "^[^#]*$"
    },
    "info": {
      "$ref": "#/$defs/info-object"
    },
    "extends": {
      "type": "string",
      "format": "uri-reference",
      "$comment": "MUST NOT contain a fragment",
      "pattern": "^[^#]*$"
    },
    "actions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/reusable-action-reference-object"
          },
          {
            "$ref": "#/$defs/action-object"
          }
        ]
      }
    },
    "components": {
      "$ref": "#/$defs/components-object"
    }
  },
  "required": [
    "overlay",
    "info",
    "actions"
  ],
  "$ref": "#/$defs/specification-extensions",
  "unevaluatedProperties": false,
  "$defs": {
    "reusable-action-reference-object": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/specification-extensions"
        },
        {
          "$ref": "#/$defs/description-field"
        },
        {
          "$ref": "#/$defs/target-field"
        }
      ],
      "properties": {
        "$ref": {
          "type": "string",
          "pattern": "^#\\/components\\/actions\\/(?:[^~/]|~0|~1)+$"
        }
      },
      "required": [
        "$ref",
        "target"
      ],
      "unevaluatedProperties": false
    },
    "reusable-action-fields-object": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/description-field"
        },
        {
          "$ref": "#/$defs/action-fields"
        },
        {
          "$ref": "#/$defs/specification-extensions"
        }
      ],
      "unevaluatedProperties": false
    },
    "reusable-action-object": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/specification-extensions"
        },
        {
          "$ref": "#/$defs/description-field"
        }
      ],
      "properties": {
        "fields": {
          "$ref": "#/$defs/reusable-action-fields-object"
        }
      },
      "unevaluatedProperties": false
    },
    "components-object": {
      "type": "object",
      "properties": {
        "actions": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/reusable-action-object"
          }
        }
      },
      "$ref": "#/$defs/specification-extensions",
      "unevaluatedProperties": false
    },
    "info-object": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      },
      "allOf": [
        {
          "$ref": "#/$defs/description-field"
        }
      ],
      "required": [
        "title",
        "version"
      ],
      "$ref": "#/$defs/specification-extensions",
      "unevaluatedProperties": false
    },
    "description-field": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        }
      }
    },
    "target-field": {
      "type": "object",
      "properties": {
        "target": {
          "type": "string",
          "pattern": "^\\$"
        }
      }
    },
    "action-fields": {
      "type": "object",
      "properties": {
        "update": {
          "type": [
            "string",
            "boolean",
            "object",
            "array",
            "number",
            "null"
          ]
        },
        "copy": {
          "type": "string"
        },
        "remove": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "action-object": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/description-field"
        },
        {
          "$ref": "#/$defs/target-field"
        },
        {
          "$ref": "#/$defs/action-fields"
        },
        {
          "$ref": "#/$defs/specification-extensions"
        }
      ],
      "required": [
        "target"
      ],
      "unevaluatedProperties": false
    },
    "specification-extensions": {
      "patternProperties": {
        "^x-": true
      }
    }
  }
}
