Skip to content

892 - 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": "Merle Grady",
    "email": "Emilio.Koelpin31@yahoo.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Quinn Lang",
    "email": "Ibrahim39@yahoo.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "f3f2ea9f-94b2-4b3d-9a88-5a0a36bd52e5"
  }
  delay_ms: 138 # simulated latency
}

See Also