Skip to main content

Configuration

Configuration is resolved with the precedence CLI arguments > config file > defaults. The resolved object is the CliConfig interface returned by resolveConfig.

CliConfig​

The central configuration type. All fields except specPath are optional.

FieldTypeDefaultDescription
specPathstringrequiredPath or http(s):// URL to the OpenAPI 3.2 JSON spec
serverUrlstring(from spec)Override the server base URL from the spec
outputDirstring"./openapi-cli-report"Directory to write report files
formatsReportFormat[]["json","cli","html"]Report formats to generate
filterFilterConfigundefinedFilter which operations to test
concurrencynumber5Max concurrent requests; integer from 1 to 100
timeoutnumber30000Per-request timeout in ms, integer from 1 to 600000 (also applies to remote spec fetch)
proxystringundefinedHTTP(S) proxy URL, e.g. http://proxy:8080
tlsTlsConfigundefinedTLS / certificate configuration
headersRecord<string, string>undefinedExtra headers sent with every request
authAuthConfigundefinedAuthentication configuration
variablesRecord<string, string>undefinedPostman {{name}} variables to inject
failOnErrorbooleantrueCLI only: return non-zero after test failure; library callers inspect the report
envFilestringundefinedPath to a .env file (KEY=VALUE per line)
grpcReflectionbooleanautomaticgRPC: explicit config wins, then the operation extension; otherwise enabled when no proto paths are provided
grpcProtoPathsstring[]undefinedgRPC: paths to .proto files or directories
mcpTransport"streamable-http" | "stdio""streamable-http"MCP: transport for MCP operations
mcpCommandstringundefinedMCP stdio: command to spawn
mcpArgsstring[]undefinedMCP stdio: command arguments
mcpCwdstringundefinedMCP stdio: working directory

ReportFormat is the union "json" | "cli" | "html".

Advanced runtime options​

The following fields are also part of CliConfig. requester, maxEvents, maxStreamMs, and maxResponseSize can be provided in a JSON config file. Pass signal, httpRuntime, and resolveTransport directly to runTests() in code after resolving the config; they are runtime objects, not JSON configuration.

interface AdvancedRuntimeOptions {
requester?: {
followRedirects?: boolean;
maxRedirects?: number;
disableCookies?: boolean;
protocolVersion?: "http1" | "http2" | "auto";
};
maxEvents?: number;
maxStreamMs?: number;
maxResponseSize?: number;
signal?: AbortSignal;
httpRuntime?: { certificates?: unknown; fileResolver?: unknown };
resolveTransport?: (target: { protocol: string; url?: string }) => Promise<
Pick<CliConfig, "proxy" | "tls" | "httpRuntime">
>;
}

requester controls HTTP redirects, cookies, and protocol selection. For HTTP/SSE execution, maxEvents defaults to 50 and maxStreamMs falls back to timeout; maxResponseSize is forwarded to the request runtime. gRPC uses maxStreamMs for its stream deadline, falling back to timeout and then 30000 ms. signal cancels a run; httpRuntime supplies HTTP certificate/file handling; resolveTransport resolves transport settings per target.

DEFAULT_CONFIG​

The built-in defaults object exported from the library:

export const DEFAULT_CONFIG: Required<
Pick<
CliConfig,
"outputDir" | "formats" | "concurrency" | "timeout" | "failOnError" | "grpcReflection" | "mcpTransport"
>
> = {
outputDir: "./openapi-cli-report",
formats: ["json", "cli", "html"],
concurrency: 5,
timeout: 30000,
failOnError: true,
grpcReflection: true,
mcpTransport: "streamable-http",
};

FilterConfig​

FieldTypeDescription
methodsstring[]Only test these HTTP methods (e.g. ["get","post"]); use lowercase in config files, while CLI input is normalized
pathsstring[]Only test paths matching any of these regex patterns (falls back to substring match)
tagsstring[]Only test operations carrying any of these tags
operationIdsstring[]Only test these exact operationId values

A filter with no keys present resolves to undefined (everything runs).

TlsConfig​

FieldTypeDescription
caCertstringPath to a CA certificate bundle (PEM)
clientCertstringPath to a client certificate (PEM) for mTLS
clientKeystringPath to a client private key (PEM) for mTLS
strictSSLbooleanSkip TLS certificate verification when false (insecure)
pfxstringPath to a PFX certificate bundle; gRPC requires PEM instead
passphrasestringPassphrase for encrypted certificate material

Note: the CLI flag --insecure maps to tls.strictSSL = false (i.e. it disables verification).

AuthConfig​

FieldTypeDescription
typeAuthConfig["type"]Auth scheme; see the supported names below
parametersRecord<string, string | number | boolean>Scheme-specific parameters passed to the request runtime
tokenstringBearer token (for type: "bearer")
usernamestringUsername (for type: "basic")
passwordstringPassword (for type: "basic")
keystringAPI key name (for type: "apikey")
valuestringAPI key value (for type: "apikey")
in"header" | "query"Where the API key is placed

Supported type values are bearer, basic, apikey, none, digest, oauth1, oauth2, jwt, hawk, aws4, ntlm, asap, and edgegrid. Availability and required parameters depend on the protocol and request runtime; specifying a name alone does not configure authentication.

At present the CLI --bearer flag only produces { type: "bearer", token }. The richer basic / apikey shapes are used when supplied from a config file.

JSON config file​

A config file is plain JSON matching Partial<CliConfig>. Pass it with --config <path> / -c. CLI arguments always win over file values.

{
"specPath": "./openapi.json",
"serverUrl": "https://api.staging.example.com",
"outputDir": "./reports",
"formats": ["json", "html"],
"concurrency": 10,
"timeout": 15000,
"failOnError": true,
"proxy": "http://proxy.corp:8080",
"tls": {
"strictSSL": true,
"caCert": "./ca-bundle.pem",
"clientCert": "./client.crt",
"clientKey": "./client.key"
},
"headers": {
"X-API-Key": "${API_KEY}",
"X-Environment": "staging"
},
"auth": {
"type": "bearer",
"token": "${BEARER_TOKEN}"
},
"variables": {
"host": "api.staging.example.com"
},
"filter": {
"methods": ["get", "post"],
"tags": ["v2", "public"],
"paths": ["^/api/v2"],
"operationIds": ["getUser", "createUser"]
},
"grpcReflection": true,
"grpcProtoPaths": ["./proto"],
"mcpTransport": "streamable-http",
"mcpCommand": "npx",
"mcpArgs": ["-y", "@modelcontextprotocol/server-everything"],
"mcpCwd": "./mcp-servers"
}

A missing config file throws Config file not found: <path>; invalid JSON throws Invalid config file (must be JSON).

Environment variable expansion​

After a .env file is loaded (via --env / envFile), ${VAR_NAME} references are expanded in these string fields:

  • serverUrl
  • proxy
  • headers values
  • auth.token
  • variables values

Example:

openapi-cli --spec openapi.json \
--server 'https://${API_HOST}/v1' \
--header 'Authorization: Bearer ${BEARER_TOKEN}'

.env behavior: existing process.env entries are not overwritten; surrounding single/double quotes are stripped; blank and # comment lines are ignored; a missing file is silently skipped.

Programmatic construction​

import { resolveConfig, DEFAULT_CONFIG } from "@powerduck/openapi-cli";

const config = resolveConfig({
spec: "./openapi.json",
server: "https://api.staging.example.com",
concurrency: 10,
method: "get",
});

resolveConfig throws "No OpenAPI spec path provided..." when no spec is supplied, and Invalid proxy URL: <url> when proxy is not a valid URL.