{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/Sharathvc23/forgetproof/main/schemas/forget-me/v1/error.schema.json",
  "title": "ForgetMe v1: Error",
  "description": "Every non-2xx answer with a JSON body: a machine code and a human sentence, plus the extra fields the spec names for some codes (operation and state on double_submit, operation on conflict, missing and unexpected on terms_incomplete, supported on unsupported_version, retry_after on 429 and 503, extension on extension_required, operation on approval_required, operation_id/revision/reason on approval_declined, scope on insufficient_scope). A 401 challenge for a missing access token has no error code (Poppy 1.0 section 7) and is not described here.",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "no_session",
        "forbidden_scope",
        "bad_request",
        "too_large",
        "bad_scope",
        "missing_reference",
        "terms_incomplete",
        "unknown_reference",
        "reference_expired",
        "conflict",
        "double_submit",
        "unknown_operation",
        "unsupported_version",
        "rate_limited",
        "not_ready",
        "scenario_expired",
        "scenario_failed",
        "busy",
        "invalid_session",
        "session_ended",
        "version_unsupported",
        "extension_required",
        "invalid_token",
        "insufficient_scope",
        "invalid_request",
        "approval_required",
        "approval_declined"
      ]
    },
    "error_description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "operation": {
      "oneOf": [
        {
          "$ref": "common.schema.json#/$defs/operation-id"
        },
        {
          "type": "null"
        },
        {
          "$ref": "common.schema.json#/$defs/poppy-operation"
        }
      ],
      "description": "On double_submit and conflict: the ForgetMe operation id. On approval_required: the Poppy operation to approve (Operations extension, version 3)."
    },
    "state": {
      "$ref": "common.schema.json#/$defs/state"
    },
    "missing": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "unexpected": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "supported": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "retry_after": {
      "type": "integer",
      "minimum": 0
    },
    "extension": {
      "type": "string",
      "minLength": 1,
      "description": "On extension_required: the extension's name."
    },
    "operation_id": {
      "$ref": "common.schema.json#/$defs/poppy-id",
      "description": "On approval_declined: the approval's operation_id."
    },
    "revision": {
      "$ref": "common.schema.json#/$defs/poppy-id",
      "description": "On approval_declined: the approval's revision."
    },
    "reason": {
      "type": "string",
      "minLength": 1,
      "description": "On approval_declined: why, in plain language for the person; no reason codes."
    },
    "scope": {
      "type": "string",
      "minLength": 1,
      "description": "On insufficient_scope: the scope the route needs (also in WWW-Authenticate)."
    }
  },
  "required": [
    "error",
    "error_description"
  ],
  "additionalProperties": true,
  "allOf": [
    {
      "if": {
        "properties": {
          "error": {
            "const": "extension_required"
          }
        },
        "required": [
          "error"
        ]
      },
      "then": {
        "required": [
          "extension"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "error": {
            "const": "approval_required"
          }
        },
        "required": [
          "error"
        ]
      },
      "then": {
        "required": [
          "operation"
        ],
        "properties": {
          "operation": {
            "$ref": "common.schema.json#/$defs/poppy-operation"
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "error": {
            "const": "approval_declined"
          }
        },
        "required": [
          "error"
        ]
      },
      "then": {
        "required": [
          "operation_id",
          "revision"
        ]
      }
    }
  ]
}
