Skip to content

1591 - 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": "Opal Koelpin",
    "email": "Darlene.Blanda27@yahoo.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Ernie Aufderhar DDS",
    "email": "Elenor.Bogisich5@hotmail.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "f7da4ecf-b550-4db9-a6d6-5f6112d01108"
  }
  delay_ms: 312 # simulated latency
}

See Also