API reference

REPL and HTTP client

The terminal REPL evaluates JavaScript against the running simulator. Start it from the CLI or call api.startRepl().

Binding or commandPurpose
contextRoot context, or contexts keyed by API group.
loadContext(path)Read a nested context; use loadContext.group(path) for multiple APIs.
storeLive application store, when one exists.
routesLoaded routes, grouped for multiple APIs.
clientRaw HTTP client supporting standard HTTP methods.
route(path)Immutable OpenAPI-aware request builder; grouped by API key for multiple APIs.
.scenarioList available scenarios.
.scenario module/functionExecute a named scenario.

Request builder methods

MethodResult
.method(method)Select the HTTP method.
.path(values)Set path parameters.
.query(values)Set query parameters.
.headers(values)Set request headers.
.cookies(values)Set cookie parameters.
.form(values)Set text form fields (URL-encoded or text-only multipart).
.body(value)Set the request body.
.ready()Report whether required parameters are supplied.
.missing()List missing required parameters.
.help()Describe the selected OpenAPI operation.
.send()Send the request.

Builder configuration methods return new builders, so requests can be reused and branched. Required-parameter checks are a preparation aid, not a replacement for server validation. See request builder for examples and response handling.

Standalone client

Import createOpenApiRouteCatalog and createRouteFunction from @counterfact/client to use the builder outside the REPL. See public packages.