Skip to content

893 - API Mock

Mock API response payloads for testing. This is an example of a MAML document.

maml
# Mock API definition
{
  endpoint: "/api/v1/users"
  method: "GET"
  status: 200
  # JSON response body
  response: """
[
  {
    "id": 1,
    "name": "Mr. Neal Hayes",
    "email": "Verona32@gmail.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Glenn Herman",
    "email": "Bertha39@yahoo.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "65effcfe-4ea9-488d-bbd2-1b593bd40a4c"
  }
  delay_ms: 368 # simulated latency
}

See Also