Example 387

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": "Marianne Thompson Sr.",
"email": "Cecil63@yahoo.com",
"role": "admin"
},
{
"id": 2,
"name": "Katrina Hauck Jr.",
"email": "Nathan38@yahoo.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "7daa583b-0b53-4a72-9c70-bf9ca6493ff0"
}
delay_ms: 125 # simulated latency
}

See also