GET /jsonapi
Returns JSON:API responses with spec-level violations. Default returns `data` as an array when a single resource is expected. Use ?mode= to isolate other violations: orphaned included resources, missing `id`, or missing `type`.
mode
data-shape-confusion (default; `data` is an array when a single resource is implied; clients that call response.data.attributes receive undefined), included-orphan (`included` contains people/99 not referenced by any relationship in `data`; JSON:API §5 requires all included resources to be linked), missing-id (resource object has no `id`; JSON:API §3.1 requires it for server-assigned IDs), type-missing (resource object has no `type`; JSON:API §3.1 requires it; clients that dispatch on type throw or fall through).
control Compare against the well-formed counterpart: not.catastrophic.io/jsonapi side-by-side
build a request:
expect: A JSON:API response with one spec violation. Served as application/vnd.api+json. The `note` field in the body explains what is wrong.
curl -si 'https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion' | grep -E '^(HTTP|content-type|x-chaos)'
import urllib.request, json
resp = urllib.request.urlopen("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion")
print("Content-Type:", resp.headers.get("Content-Type"))
print("X-Chaos-Jsonapi-Mode:", resp.headers.get("X-Chaos-Jsonapi-Mode"))
body = json.loads(resp.read())
data = body.get("data")
print("data is array:", isinstance(data, list))
if isinstance(data, dict):
print("id present:", "id" in data)
print("type present:", "type" in data)
print("note:", body.get("note"))
const res = await fetch("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion");
const body = await res.json();
console.log("Content-Type:", res.headers.get("content-type"));
console.log("X-Chaos-Jsonapi-Mode:", res.headers.get("x-chaos-jsonapi-mode"));
console.log("data is array:", Array.isArray(body.data));
if (!Array.isArray(body.data)) {
console.log("id present:", "id" in body.data);
console.log("type present:", "type" in body.data);
}
console.log("note:", body.note);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
resp, _ := http.Get("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion")
defer resp.Body.Close()
raw, _ := io.ReadAll(resp.Body)
var body map[string]any
json.Unmarshal(raw, &body)
fmt.Println("Content-Type:", resp.Header.Get("Content-Type"))
fmt.Println("X-Chaos-Jsonapi-Mode:", resp.Header.Get("X-Chaos-Jsonapi-Mode"))
_, dataIsArray := body["data"].([]any)
fmt.Println("data is array:", dataIsArray)
}
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }
fn main() -> Result<(), Box> {
let resp = reqwest::blocking::get("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion")?;
println!("Content-Type: {:?}", resp.headers().get("content-type"));
println!("X-Chaos-Jsonapi-Mode: {:?}", resp.headers().get("x-chaos-jsonapi-mode"));
let body: serde_json::Value = resp.json()?;
println!("data is array: {}", body["data"].is_array());
Ok(())
}
import java.net.URI;
import java.net.http.*;
public class JsonApiChaos {
public static void main(String[] args) throws Exception {
var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion")).build();
var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("Content-Type: " +
resp.headers().firstValue("Content-Type").orElse(""));
System.out.println("X-Chaos-Jsonapi-Mode: " +
resp.headers().firstValue("X-Chaos-Jsonapi-Mode").orElse(""));
System.out.println("Body: " + resp.body());
}
}
using var client = new HttpClient();
var resp = await client.GetAsync("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion");
Console.WriteLine($"Content-Type: {resp.Content.Headers.ContentType}");
Console.WriteLine($"X-Chaos-Jsonapi-Mode: " +
$"{resp.Headers.GetValues("X-Chaos-Jsonapi-Mode").FirstOrDefault()}");
var body = await resp.Content.ReadAsStringAsync();
Console.WriteLine($"Body: {body}");
require "net/http"
require "json"
uri = URI("https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion")
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
res = http.get(uri.request_uri)
puts "Content-Type: #{res['Content-Type']}"
puts "X-Chaos-Jsonapi-Mode: #{res['X-Chaos-Jsonapi-Mode']}"
body = JSON.parse(res.body)
puts "data is array: #{body['data'].is_a?(Array)}"
end
$r = Invoke-RestMethod -Uri 'https://chaos.catastrophic.io/jsonapi?mode=data-shape-confusion' -ResponseHeadersVariable h
"Content-Type: $($h['Content-Type'])"
"X-Chaos-Jsonapi-Mode: $($h['X-Chaos-Jsonapi-Mode'])"
"data is array: $($r.data -is [array])"
headers
body