Vai al contenuto principale
CuteJSON
↑↓ Naviga Enter Seleziona Esc Chiudi

Schema risposta errore

Intermedio JSON Schema

Un JSON Schema per validare risposte di errore API con dettagli errore strutturati. Un esempio realistico per il tuo progetto o i tuoi test.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ErrorResponse",
  "type": "object",
  "properties": {
    "status": { "const": "error" },
    "error": {
      "type": "object",
      "properties": {
        "code": { "type": "string" },
        "message": { "type": "string" },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "field": { "type": "string" },
              "message": { "type": "string" }
            }
          }
        }
      },
      "required": ["code", "message"]
    },
    "requestId": { "type": "string" }
  },
  "required": ["status", "error"]
}
Esempi JSON