Skip to main content

openapi-to-k6 options

Every configuration option of @spartaficial/openapi-to-k6: its type, its default and where it may be set. This page is generated from the generator's configuration schema, so it cannot drift from the code. For how the options combine, read the k6 generator guide; for where the options go, read Configuration files; for what the other generators accept, read Option parity.

Spec entry options​

Each entry in specs accepts these options. The 3 required options come first, then the rest alphabetically. The "In defaults" column says whether the option may also be set once, under defaults, for every entry.

OptionTypeDefaultIn defaultsDescription
inputstringrequirednoInput OpenAPI specification file path (YAML or JSON)
outputClientstringrequirednoOutput client file path for generated K6 client (passthrough layer)
outputTypesstringrequirednoOutput file path for generated types
basePathstring—yesBase path to prepend to all API endpoints
batchSizenumber > 010yesBatch size for parallel execution
defaultNullablebooleanfalseyesTreat all properties as nullable by default when not explicitly specified
enumFormat"enum" | "union" | "const-object""union"yesFormat for the enums in the generated types file
fileHeaderstring[]—yesCustom comment lines to add at the very top of generated files
ignoreHeadersstring[]—yesHeader parameters to ignore during generation
includeDescriptionsbooleantrueyesWhether to include JSDoc comments with descriptions
namestring—noA label for this specification entry
operationFiltersobject—yesOperation filtering options (see the table below)
outputServicestring—noOutput service file path for generated K6 service (validation layer)
preferredContentTypesstring[]["application/json"]yesPreferred content types for request/response handling, in order of priority
prefixstring—yesPrefix to add to all generated type/schema names
refMappingsRecord<string, string>—yesRedirect remote $ref documents to local files, keyed by URL prefix
showStatsbooleantrueyesWhether to show generation statistics
showWarningsbooleantrueyesEnable or disable warning messages during generation
stripPathPrefixstring—yesStrip a common prefix from all paths before processing
stripSchemaPrefixstring | string[]—yesStrip a common prefix from all schema names before processing
suffixstring—yesSuffix to add to generated type/schema names
useOperationIdbooleanfalseyesWhether to use operationId from OpenAPI spec for generated naming

operationFilters​

Options of the operationFilters object. These are the operation filters every generator shares.

OptionTypeDefaultDescription
excludeDeprecatedbooleanfalseExclude operations marked as deprecated
excludeMethodsstring[]—Exclude operations with one of these HTTP methods
excludeOperationIdsstring[]—Exclude operations whose operationId matches one of these patterns
excludePathsstring[]—Exclude operations whose path matches one of these patterns
excludeTagsstring[]—Exclude operations that carry any of these tags
includeMethodsstring[]—Include only operations with one of these HTTP methods
includeOperationIdsstring[]—Include only operations whose operationId matches one of these patterns
includePathsstring[]—Include only operations whose path matches one of these patterns
includeTagsstring[]—Include only operations that carry at least one of these tags

Config file​

The generator reads openapi-to-k6.config.ts, openapi-to-k6.config.json or an "openapi-to-k6" key in package.json. Whatever the format, the file has this shape:

import { defineConfig } from "@spartaficial/openapi-to-k6";

export default defineConfig({
// Optional. Any of the 17 options marked "yes" above, applied to every entry in specs
defaults: {},
// Required. One entry per specification; an entry's own options override defaults
specs: [{ input: "openapi.yaml", outputClient: "k6/api-client.ts", outputTypes: "k6/api-types.ts" }],
// Optional. How several entries are processed: "parallel" or "sequential"; default "parallel"
executionMode: "parallel",
});

defaults takes the options marked "yes" in the "In defaults" column; paths and name are always per entry. executionMode only matters when specs has more than one entry.