Skip to content

098 - 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": "Ryan Kozey",
    "email": "Providenci79@yahoo.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Winston Yundt",
    "email": "Ewell8@hotmail.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "5f1d3f78-c24b-481d-8361-4b56f670bff0"
  }
  delay_ms: 339 # simulated latency
}

See Also