Example 589

API Mock

Mock API response payloads for testing.

# Mock API definition
{
endpoint: "/api/v1/users"
method: "GET"
status: 200
# JSON response body
response: """
[
{
"id": 1,
"name": "Emmalee Goyette",
"email": "Andy_Kshlerin-Champlin80@hotmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Dwayne Champlin-Daugherty",
"email": "Ulices.Rice@gmail.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "54efcc4a-f11e-4354-89f5-48acf9918474"
}
delay_ms: 417 # simulated latency
}

See also