Skip to main content

Configuration

Configuration is split into three layers: client/debugger factory options, the SendOptions object passed to prepare() and send(), and per-protocol options.

Factory Options​

CreateClientOptions​

Passed to createClient(options?). All fields are optional.

FieldTypeDescription
writeBackWriteBackOptionsControl how responses are merged back into the spec
responseToResponseOptionsControl how response objects are normalized
import { createClient } from "@powerduck/openapi-request";

const client = createClient({
writeBack: {
overwriteExamples: true,
// ... other WriteBackOptions
},
response: {
includeExamples: false,
// ... other ToResponseOptions
},
});

DebuggerOptions​

Passed to createDebugger(config?). All fields are optional.

FieldTypeDescription
adaptersProtocolAdapter[]Custom adapter list (replaces all defaults)
extraAdaptersProtocolAdapter[]Extra adapters added to the default registry
writeBackWriteBackOptionsWrite-back options
responseToResponseOptionsResponse normalization options
writeBackTruncatedbooleanWrite back schema inferred from truncated streams (default: true)
import { createDebugger, HttpAdapter, WebSocketAdapter } from "@powerduck/openapi-request";

// Use only HTTP and WebSocket adapters
const debugger1 = createDebugger({
adapters: [new HttpAdapter(), new WebSocketAdapter()],
});

// Add a custom adapter to the defaults
const debugger2 = createDebugger({
extraAdapters: [new MyCustomAdapter()],
writeBackTruncated: true,
});

Write-back and captured examples​

WriteBackOptions supports strategy ("merge" or "replace", default "merge"), keepExistingDescription (default true), allowedStatusCodes (empty means all), protectComponentRefs (default true), overwriteExamples (default true), and requirePassingTests. The send pipeline applies the test gate; calling writeBackResponse directly does not.

ToResponseOptions supports includeExamples (default true), maxExampleChars (default 4000), and maxEventPreviewChars (default 200). Disable captured examples or review them before publishing: live responses can contain credentials or personal data.

The send pipeline normally returns a modified copy in patchedSpec; it does not mutate the input document or save a file. Set per-call writeBack: false to skip that step. The factory's writeBack object configures merging; the per-call boolean enables or disables it.

SendOptions​

The primary input object for prepare() and send(). This is where you pass the spec, target, values, and all request-level configuration.

FieldTypeRequiredDescription
specOpenApiDocumentYesThe complete OpenAPI 3.2 document
targetOperationTargetYesOperation identifier (see below)
valuesRequestValuesNoConcrete values for path/query/header/cookie/body
serverUrlstringNoOverrides spec.servers[0].url
serverVariablesRecord<string, string>NoServer URL template variables
variablesRecord<string, string>NoEnvironment variables referenced as {{name}}
globalsRecord<string, string>NoPostman-style globals
localVariablesRecord<string, string>NoLocal variables
collectionVariablesRecord<string, string>NoCollection-level variables
authAuthConfigNoAuthentication configuration
scriptsScriptConfigNoPre-request and test scripts
runnerRuntimeRunOptionsNoFull postman-runtime option passthrough (highest precedence)
websocketWebSocketOptionsNoWebSocket-specific options
graphqlGraphQLOptionsNoGraphQL-specific options
mcpMcpOptionsNoMCP-specific options
grpcanyNogRPC-specific options
timeoutnumberNoPer-request timeout in ms (convenience shortcut for runner.timeout.request)

SendOptions also accepts these execution and streaming controls:

FieldTypeDescription
fetchtypeof fetchHost-supplied isolated fetch transport where supported; HTTP/SSE still use postman-runtime.
writeBackbooleanSet to false to leave patchedSpec undefined while still producing responseFragment.
signalAbortSignalCancel execution or sampling; a partial result can still be returned.
maxEventsnumberMaximum retained streaming events.
maxStreamMsnumberMaximum streaming sampling duration in milliseconds.
maxResponseSizenumberResponse byte limit.
maxBufferCharsnumberSSE parser buffer limit before an event boundary; default 4194304 characters.
maxEventCharsnumberRetained data limit per SSE event; default 1048576 characters.
inheritEventIdbooleanInherit the last SSE event ID when absent; default true. Set to false for stricter schema inference.
onEvent(event: StreamEvent) => voidReceive streaming events.
onConsole(log: ConsoleLog) => voidReceive script console output.
onAssertion(assertion: AssertionResult) => voidReceive assertion results.
onResponseStart(info: ResponseStartInfo) => voidInspect early HTTP/SSE headers and streaming classification.
onOpen(info) => voidReceive WebSocket connection details: URL, protocol and headers.

Protocol adapters may interpret limits differently. Keep UI callbacks lightweight; throwing callbacks are caught by the execution layer. For HTTP requester settings, use runner.requester; its maxResponseSize must be positive if provided, not zero.

OperationTarget​

Identifies a single operation. Prefer either operationId or method + path. If both are provided, operationId takes precedence.

FieldTypeDescription
operationIdstringAlternative lookup key; takes precedence over path + method
methodstringHTTP method, case-insensitive. Requires path.
pathstringTemplated path, e.g. /users/{id}. Requires method.
// By operationId (recommended)
const result1 = await client.send({
spec,
target: { operationId: "getUserById" },
});

// By method + path
const result2 = await client.send({
spec,
target: { method: "GET", path: "/users/{id}" },
});

RequestValues​

Concrete values injected into the generated request.

FieldTypeDescription
pathRecord<string, unknown>Path parameter values
queryRecord<string, unknown>Query parameter values
headerRecord<string, unknown>Header values
cookieRecord<string, unknown>Cookie values
querystringstringRaw, pre-encoded query string (OpenAPI 3.2 querystring location)
bodyunknownRequest body
contentTypestringForce a specific request media type when the operation declares several
const result = await client.send({
spec,
target: { operationId: "updateUser" },
values: {
path: { id: "42" },
query: { version: "2" },
header: { "X-Request-Id": "abc-123" },
body: { name: "Alice", email: "alice@example.com" },
contentType: "application/json",
},
});

AuthConfig​

FieldTypeDescription
typeAuthConfig["type"]Auth type
tokenstringBearer token (for type: "bearer")
usernamestringBasic auth username (for type: "basic")
passwordstringBasic auth password (for type: "basic")
keystringAPI key name (for type: "apikey")
valuestringAPI key value (for type: "apikey")
in"header" | "query"API key location (for type: "apikey")
// Bearer token
const result1 = await client.send({
spec,
target: { operationId: "getUser" },
auth: { type: "bearer", token: "your-jwt-token" },
});

// Basic auth
const result2 = await client.send({
spec,
target: { operationId: "getUser" },
auth: { type: "basic", username: "admin", password: "secret" },
});

// API key in header
const result3 = await client.send({
spec,
target: { operationId: "getUser" },
auth: { type: "apikey", key: "X-API-Key", value: "key-123", in: "header" },
});

Advanced auth types are digest, oauth1, oauth2, jwt, hawk, aws4, ntlm, asap, and edgegrid. Pass their HTTP/SSE/GraphQL Postman helper fields through parameters: Record<string, string | boolean | number>. The optional oauth2: OAuth2FlowConfig enables token acquisition and refresh for the OAuth 2.0 type; do not assume every auth helper applies to every protocol.

ScriptConfig​

FieldTypeDescription
collectionPreRequestScriptSource | ScriptSource[]Collection-level pre-request scripts
collectionTestScriptSource | ScriptSource[]Collection-level test scripts
preRequestScriptSource | ScriptSource[]Request-level pre-request scripts
testScriptSource | ScriptSource[]Request-level test scripts
fromSpecExtensionsbooleanRead x-postman-scripts from the spec (default: true)
captureLastResponsebooleanAppend built-in helper exposing last response to later requests

ScriptSource:

interface ScriptSource {
exec: string | string[]; // Script body, either a single string or array of lines
id?: string; // Optional identifier surfaced in script results
}

Set scripts.fromSpecExtensions: false when you do not intend to execute scripts embedded in an imported specification. The current default is true; do not rely on a future default change.

Protocol-Specific Options​

HTTP / SSE​

HTTP is the default adapter. Declared text/event-stream content indicates SSE intent; execution also classifies the live response when headers arrive. probeStreamingResponse() is a separate explicit probe, not an automatic prerequisite for every call.

No additional configuration is required for basic HTTP requests. Use SendOptions.runner for advanced postman-runtime configuration.

WebSocket​

import { createManualSession } from "@powerduck/openapi-request";

const session = createManualSession({
kind: "websocket",
url: "wss://api.example.com/ws",
// Manual-session options are distinct from SendOptions.websocket.
});

MCP​

import { createManualSession } from "@powerduck/openapi-request";

const session = createManualSession({
kind: "mcp",
endpoint: "https://api.example.com/mcp",
});

The default MCP manual session uses Streamable HTTP and endpoint. For stdio, pass kind: "mcp", transport: "stdio", and a local command with optional args; starting that session launches the configured process.

gRPC​

gRPC requires an address plus a descriptor source (.proto files or server reflection), and a fully-qualified service and method:

import { createManualSession } from "@powerduck/openapi-request";

const session = createManualSession({
kind: "grpc",
address: "localhost:50051",
service: "powerduck.examples.Echo",
method: "Echo",
protoPaths: ["./echo.proto"],
});

Manual session factories return an unopened session. Call open() before sending, and close() during cleanup. The gRPC example requires a matching local server and proto file; manual-session options are not the same object as SendOptions.grpc.

Complete Example​

import { createClient } from "@powerduck/openapi-request";

const client = createClient({
writeBack: { overwriteExamples: true },
});

const result = await client.send({
spec: openApiDocument,
target: { operationId: "updateUser" },
values: {
path: { id: "42" },
query: { verbose: "true" },
header: { "X-Request-Id": "req-abc" },
body: { name: "Alice", email: "alice@example.com" },
},
serverUrl: "https://api.staging.example.com",
auth: { type: "bearer", token: "staging-token" },
timeout: 10000,
variables: {
environment: "staging",
},
});

console.log(result.response.status);
console.log(result.response.body);
console.log(result.response.headers);

Next Steps​