{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fingertrackid.dev/schemas/assessment-problem.v1.schema.json",
  "title": "AssessmentProblemV1",
  "description": "Closed RFC 9457 Problems for assessment v1, including an authenticated exact result beyond its applied history period.",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "enum": [
        "https://fingertrackid.dev/problems/validation-failed",
        "https://fingertrackid.dev/problems/event-context-invalid",
        "https://fingertrackid.dev/problems/occurred-at-out-of-window",
        "https://fingertrackid.dev/problems/authentication-failed",
        "https://fingertrackid.dev/problems/timestamp-out-of-window",
        "https://fingertrackid.dev/problems/request-replayed",
        "https://fingertrackid.dev/problems/forbidden",
        "https://fingertrackid.dev/problems/idempotency-conflict",
        "https://fingertrackid.dev/problems/binding-conflict",
        "https://fingertrackid.dev/problems/assessment-result-expired",
        "https://fingertrackid.dev/problems/payload-too-large",
        "https://fingertrackid.dev/problems/unsupported-media-type",
        "https://fingertrackid.dev/problems/rate-limited",
        "https://fingertrackid.dev/problems/internal",
        "https://fingertrackid.dev/problems/assessment-unavailable"
      ]
    },
    "title": { "type": "string", "minLength": 1 },
    "status": { "type": "integer", "minimum": 400, "maximum": 599 },
    "detail": { "type": "string" },
    "instance": { "type": "string" },
    "correlation_id": { "type": "string", "minLength": 1, "maxLength": 128 },
    "retryable": { "type": "boolean" },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "pointer": { "type": "string", "minLength": 1 },
          "code": { "type": "string", "minLength": 1 }
        },
        "required": ["pointer", "code"],
        "additionalProperties": false
      }
    }
  },
  "required": ["type", "title", "status", "retryable"],
  "additionalProperties": false,
  "allOf": [
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/validation-failed" },
            "status": { "const": 400 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/event-context-invalid" },
            "status": { "const": 400 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "https://fingertrackid.dev/problems/occurred-at-out-of-window"
            },
            "status": { "const": 400 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/authentication-failed" },
            "title": { "const": "Autenticação falhou" },
            "status": { "const": 401 },
            "retryable": { "const": false },
            "detail": false,
            "errors": false
          },
          "required": ["type", "title", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "https://fingertrackid.dev/problems/timestamp-out-of-window"
            },
            "status": { "const": 401 },
            "retryable": { "const": true }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/request-replayed" },
            "status": { "const": 401 },
            "retryable": { "const": true }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/forbidden" },
            "status": { "const": 403 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/idempotency-conflict" },
            "status": { "const": 409 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/binding-conflict" },
            "status": { "const": 409 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/assessment-result-expired" },
            "title": { "const": "Assessment result expired" },
            "status": { "const": 410 },
            "retryable": { "const": false },
            "detail": false,
            "instance": false,
            "errors": false
          },
          "required": ["type", "title", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/payload-too-large" },
            "status": { "const": 413 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/unsupported-media-type" },
            "status": { "const": 415 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/rate-limited" },
            "status": { "const": 429 },
            "retryable": { "const": true }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/internal" },
            "status": { "const": 500 },
            "retryable": { "const": false }
          },
          "required": ["type", "status", "retryable"]
        },
        {
          "type": "object",
          "properties": {
            "type": { "const": "https://fingertrackid.dev/problems/assessment-unavailable" },
            "status": { "const": 503 },
            "retryable": { "const": true }
          },
          "required": ["type", "status", "retryable"]
        }
      ]
    },
    {
      "if": {
        "properties": {
          "type": { "const": "https://fingertrackid.dev/problems/validation-failed" }
        },
        "required": ["type"]
      },
      "else": { "properties": { "errors": false } }
    }
  ]
}
