{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openfreytprotocol.example/schemas/problem-detail.schema.json",
  "title": "ProblemDetail",
  "description": "RFC 9457 Problem Details for HTTP APIs — base schema. Extended by the OpenFreyt Protocol error catalogue (specification/errors/error-catalogue.md) with protocol-specific type URIs and extension fields.",
  "type": "object",
  "required": ["type", "title", "status"],
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "description": "URI identifying the problem type. Protocol-specific codes use the URN scheme: urn:freyt:protocol:error:{code}."
    },
    "title": {
      "type": "string",
      "description": "Short, human-readable summary of the problem type. Fixed per type URI; MUST NOT vary across occurrences of the same type."
    },
    "status": {
      "type": "integer",
      "minimum": 400,
      "maximum": 599,
      "description": "HTTP status code generated by the origin server."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation specific to this occurrence of the problem."
    },
    "instance": {
      "type": "string",
      "format": "uri-reference",
      "description": "URI reference that identifies the specific occurrence of the problem."
    },
    "correlationId": {
      "type": "string",
      "description": "Broker-assigned correlation identifier for distributed tracing and support lookup."
    },
    "errors": {
      "type": "array",
      "description": "Field-level validation errors (present on type validation-error).",
      "items": {
        "type": "object",
        "required": ["field", "message"],
        "properties": {
          "field": {
            "type": "string",
            "description": "JSON Pointer (RFC 6901) to the field that failed validation."
          },
          "message": {
            "type": "string",
            "description": "Human-readable description of the validation failure."
          },
          "code": {
            "type": "string",
            "description": "Machine-readable error code for the validation failure."
          }
        }
      }
    }
  }
}
