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: {
mergeExamples: true,
// ... other WriteBackOptions
},
response: {
preserveOriginalBody: 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,
});

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
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)

OperationTarget

Identifies a single operation. Use operationId OR method + path (not both).

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
type"bearer" | "basic" | "apikey" | "none"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" },
});

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
}

Protocol-Specific Options

HTTP / SSE

HTTP is the default adapter. Streaming is detected automatically from declared text/event-stream content type (SSE) or by probing live response headers with probeStreamingResponse().

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

WebSocket

const session = createManualSession({
protocol: "websocket",
url: "wss://api.example.com/ws",
// WebSocketOptions can be passed through SendOptions.websocket
});

MCP

const session = createManualSession({
protocol: "mcp",
transport: "http", // or "stdio"
url: "https://api.example.com/mcp",
});

gRPC

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

const session = createManualSession({
protocol: "grpc",
url: "grpc.example.com:50051",
// gRPC options passed through SendOptions.grpc
});

Complete Example

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

const client = createClient({
writeBack: { mergeExamples: 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