Skip to content

1996 - 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": "Glenda Donnelly",
    "email": "Grant_Hermann41@gmail.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Adrian Hills-Paucek",
    "email": "Dave83@yahoo.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "8dc5d9de-883e-4841-bde4-39b6e3978340"
  }
  delay_ms: 123 # simulated latency
}

See Also