Skip to content

389 - 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": "Lydia Walter Jr.",
    "email": "Emanuel_McCullough@yahoo.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Bennie Boyle",
    "email": "Newell_Osinski@gmail.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "7a218884-8379-4079-8788-e5840369a8cd"
  }
  delay_ms: 392 # simulated latency
}

See Also