Skip to content

Latest commit

 

History

History
53 lines (49 loc) · 3 KB

reference.md

File metadata and controls

53 lines (49 loc) · 3 KB

Reference (types)

  • type: server
  • title: string
  • description: string (supports Markdown)
  • tags: string[]
  • import: record<string, string> — see Data imports
  • protocol: http | https | ws | env token (e:MOCK_PROTOCOL / <<e:MOCK_PROTOCOL>>; default http)
  • port: number (1–65535) | env token (e:MOCK_PORT / <<e:MOCK_PORT>>) — required
  • connection: object — see TLS
    • mode: plain | tls | mtls (default plain; https implies tls when omitted)
    • cert: string (path relative to the .mmt file)
    • key: string
    • client_ca: string (required when mode is mtls)
  • cors: boolean
  • delay: number (global response delay in ms; default 0)
  • headers: record<string, string> (applied to all endpoint responses)
  • endpoints: array of endpoint objects — see Endpoints
  • proxy: string (forward unmatched requests to a real backend URL)
  • fallback: object (response when no endpoint matches)
    • status: number (default 404)
    • format: json | xml | xmle | text | urlencoded
    • headers: record<string, string>
    • body: string, object, or array

HTTP endpoint (protocol: http | https)

  • method: HTTP verb | env token — required unless reflect: true
  • path: string — required (supports :param segments)
  • name: string (optional label; must be unique within the file)
  • match: object (all listed rules must match)
    • body: record<string, JSONValue> — dotted paths + check/expect operators (nested maps still work)
    • headers: record<string, string> — same operators; header names are case-insensitive
    • query: record<string, string> — same path/operator rules as body
    • When several endpoints share method+path, a successful match wins over a bare (no-match) endpoint even if the catch-all is listed first. Among successful filters, file order wins.
  • status: number (100–599; default 200)
  • format: json | xml | xmle | text | urlencoded
  • headers: record<string, string>
  • body: string, object, or array (supports ${url.*}, ${body.*}, ${header.*}, ${query.*}, e:, r:, c: — see Tokens)
  • delay: number (per-endpoint delay in ms)
  • reflect: boolean (echo the request back as the response)

WebSocket endpoint (protocol: ws)

  • path: string — required
  • reflect: boolean
  • body: string, object, or array (initial/connect response)
  • format: json | xml | xmle | text | urlencoded
  • messages: array of { match?, body?, format?, delay? } (reply rules for incoming messages)

Notes:

  • Mock server files are not run directly from the CLI — they start from tests (run step) or suites (servers: / inline items). See CLI.
  • port and protocol accept env tokens resolved at runtime from the active environment.
  • YAML comments (#) are preserved when you format the file (Format Document).