{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trooth.co/schemas/problem-catalog.v1.schema.json",
  "title": "Trooth problem catalog, version 1",
  "description": "The registry.",
  "type": "object",
  "required": [
    "format",
    "media_type",
    "next_actions",
    "problems",
    "how_to_read"
  ],
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "trooth.problem-catalog.v1",
      "description": "Names this shape."
    },
    "media_type": {
      "const": "application/problem+json",
      "description": "The media type of every problem document."
    },
    "next_actions": {
      "type": "array",
      "description": "Every next_action value.",
      "items": {
        "enum": [
          "retry_later",
          "fix_request",
          "start_over",
          "resync",
          "use_current_record",
          "none"
        ],
        "description": "A next action."
      }
    },
    "problems": {
      "type": "array",
      "description": "One entry per code.",
      "items": {
        "type": "object",
        "description": "A code.",
        "required": [
          "code",
          "type",
          "status",
          "title",
          "retryable",
          "next_action",
          "terminal"
        ],
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "description": "The code; switch on this."
          },
          "type": {
            "type": "string",
            "description": "The RFC 9457 type URI."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status.",
            "minimum": 100
          },
          "title": {
            "type": "string",
            "description": "The fixed title."
          },
          "retryable": {
            "type": "boolean",
            "description": "True when the same request may succeed after retry_after."
          },
          "next_action": {
            "enum": [
              "retry_later",
              "fix_request",
              "start_over",
              "resync",
              "use_current_record",
              "none"
            ],
            "description": "What to do next."
          },
          "terminal": {
            "type": "boolean",
            "description": "True when repeating the same request cannot change the answer; exactly not retryable."
          }
        }
      }
    },
    "how_to_read": {
      "type": "string",
      "description": "How to read this catalog."
    }
  }
}
