Skip to content

895 - 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": "Rosalinda Thompson",
    "email": "Tierra76@hotmail.com",
    "role": "admin"
  },
  {
    "id": 2,
    "name": "Berta Langworth V",
    "email": "Roberto.Wehner98@yahoo.com",
    "role": "user"
  }
]
"""

  # Response headers
  headers: {
    Content-Type: "application/json"
    X-Total-Count: "2"
    X-Request-Id: "99f8aedd-e60b-4288-986b-6cdd54af5d3e"
  }
  delay_ms: 338 # simulated latency
}

See Also