Example 697

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. Toby Bergstrom-Brown PhD",
"email": "Geovany.Powlowski@gmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Carl Ziemann",
"email": "Emily_OHara@yahoo.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "4c0e8154-879b-4a4d-af6c-00b9f6960231"
}
delay_ms: 384 # simulated latency
}

See also