{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:registry-error:0.1",
  "title": "Błąd Junexis Registry 0.1",
  "oneOf": [
    { "$ref": "#/$defs/notFound" },
    { "$ref": "#/$defs/conflict" },
    { "$ref": "#/$defs/payloadTooLarge" },
    { "$ref": "#/$defs/rateLimited" },
    { "$ref": "#/$defs/serverFailure" }
  ],
  "$defs": {
    "notFound": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "code", "classification", "retryable"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-error/0.1" },
        "status": { "const": 404 },
        "code": { "const": "artifact-not-found" },
        "classification": { "const": "not-found" },
        "retryable": { "const": false },
        "correlationId": { "$ref": "#/$defs/correlationId" }
      }
    },
    "conflict": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "code", "classification", "retryable"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-error/0.1" },
        "status": { "const": 409 },
        "code": { "const": "artifact-conflict" },
        "classification": { "const": "conflict" },
        "retryable": { "const": false },
        "correlationId": { "$ref": "#/$defs/correlationId" }
      }
    },
    "payloadTooLarge": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "code", "classification", "retryable"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-error/0.1" },
        "status": { "const": 413 },
        "code": { "const": "payload-too-large" },
        "classification": { "const": "request-limit" },
        "retryable": { "const": false },
        "correlationId": { "$ref": "#/$defs/correlationId" }
      }
    },
    "rateLimited": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "code", "classification", "retryable"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-error/0.1" },
        "status": { "const": 429 },
        "code": { "const": "rate-limited" },
        "classification": { "const": "rate-limit" },
        "retryable": { "const": true },
        "retryAfterSeconds": { "$ref": "#/$defs/retryAfterSeconds" },
        "correlationId": { "$ref": "#/$defs/correlationId" }
      }
    },
    "serverFailure": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "status", "code", "classification", "retryable"],
      "properties": {
        "schemaVersion": { "const": "junexis.registry-error/0.1" },
        "status": { "type": "integer", "minimum": 500, "maximum": 599 },
        "code": { "const": "registry-unavailable" },
        "classification": { "const": "server-failure" },
        "retryable": { "const": true },
        "retryAfterSeconds": { "$ref": "#/$defs/retryAfterSeconds" },
        "correlationId": { "$ref": "#/$defs/correlationId" }
      }
    },
    "retryAfterSeconds": { "type": "integer", "minimum": 0, "maximum": 86400 },
    "correlationId": { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?![\\s\\S])" }
  }
}