Skip to content

096 - 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": "Susie Hirthe",
    "email": "Daphne.Klein@gmail.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Lester Kreiger",
    "email": "Muhammad5@hotmail.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "9d56a4c6-0110-4b14-a05f-c44db512e512"
  }
  delay_ms: 202 # simulated latency
}

See Also