Skip to content

3391 - 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": "Naomi Kulas",
    "email": "Jack.Funk@gmail.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Alessandro Jacobson-Miller",
    "email": "Napoleon.Schultz29@gmail.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "5e444333-733c-412b-bb94-27580a6db3ed"
  }
  delay_ms: 233 # simulated latency
}

See Also