Example 4390

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": "Mr. Matthew Kirlin",
"email": "Consuelo.Lemke@hotmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Ryan VonRueden",
"email": "Bennie_Hermiston96@yahoo.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "777dc053-db9f-4aec-964e-49fab4b1da57"
}
delay_ms: 186 # simulated latency
}

See also