04Reference
Config options
Every option with its type, default and description, read from the schema that validates configs.
How configs are loaded, which formats exist and how options combine is explained in config files. This page lists every option.
Config files are named swaggerz.config.<ext>, with the extensions .ts, .mts, .cts, .js, .mjs, .cjs, .json, .yaml and .yml. JSON and YAML configs are validated against the same schema in editors (swaggerz/config.schema.json). Options marked code onlytake functions and exist only in TypeScript and JavaScript configs.
$schema
$schemastringJSON Schema used by editors for completion and validation.
spec
specrequiredobjectThe specification to generate from.
spec.versionrequired'2.0' | '3.0' | '3.1' | '3.2' | 'auto'Specification version the input must declare: '2.0' (Swagger), '3.0', '3.1', '3.2', or 'auto' for any supported version.
spec.inputrequiredstring· not emptyPath (relative to the config file) or http(s) URL of a JSON or YAML document.
spec.refsobjectExternal reference policy.
spec.refs.external'none' | 'local' | 'remote'· default"local"Which external $refs may be followed: 'none', 'local' files inside allowedDirectories, or 'remote' URLs on allowedHosts as well.
spec.refs.allowedDirectoriesstring[]Directories local references may read. Defaults to the project root and the directory of the specification.
spec.refs.allowedHostsstring[]Hosts remote references may be fetched from, e.g. 'schemas.example.com' or '*.example.com'.
spec.refs.maxDocumentsnumber· default5000· ≥ 1, integerMaximum number of documents a description may consist of.
spec.fetchobjectOptions for fetching remote documents.
spec.fetch.headersRecord<string, string>Headers sent with remote documents (only to the origin of spec.input).
spec.fetch.timeoutnumber· default30000· ≥ 1, integerTimeout in milliseconds.
spec.fetch.maxBytesnumber· default52428800· ≥ 1, integerMaximum document size in bytes.
spec.fetch.pollboolean | numberPoll remote documents for changes in
generate --watchand the dashboard: true (every 2000 ms), an interval in milliseconds, or false. By default only documents on loopback hosts (localhost, 127.0.0.1, [::1]) are polled.spec.overlaysstring[]OpenAPI Overlay documents (1.0, 1.1 or 1.2) applied in order to the specification before it is parsed: paths relative to the config file, or http(s) URLs.
output
outputobjectWhere and how generated files are written.
output.directorystring· default"./src/generated/api"· not emptyOutput directory, relative to the config file.
output.language'typescript' | 'javascript'· default"typescript"Generate TypeScript, or JavaScript with JSDoc and .d.ts declarations.
output.moduleFormat'esm'· default"esm"Only ES modules are generated.
output.cleanboolean· defaulttrueRemove generated files that are no longer produced (only files recorded in the manifest).
output.declarationsboolean· defaulttrueJavaScript output: emit .d.ts declarations next to each module.
output.importExtension'.js' | '.ts' | 'none'· default".js"Extension used in relative imports between generated modules.
output.barrelboolean· defaulttrueEmit index barrels.
output.groupBy'tag' | 'none'· default"tag"Group operation modules in directories by their first tag.
output.models'all' | 'used'· default"all"Emit every named schema ('all') or only those operations use ('used').
output.webhooksboolean· defaulttrueGenerate payload types and handler signatures for webhooks and callbacks.
output.bannerstringExtra text for the header comment of every generated file.
client
clientobjectDefaults of the generated HTTP client.
client.adapter'fetch' | 'axios'· default"fetch"HTTP transport: 'fetch' (no dependencies) or 'axios'.
client.baseUrlstringBase URL compiled into the client. Defaults to the first server of the specification.
client.operationServersboolean· defaulttrueSend operations that declare their own
serversto that server instead of the base URL.client.includeCredentialsboolean· defaultfalseSend cookies with cross-origin requests.
client.headersRecord<string, string>Static headers sent with every request.
client.timeoutnumber· ≥ 0, integerDefault request timeout in milliseconds (0 disables it).
client.responseStyle'data' | 'full'· default"data"'data' resolves with the body; 'full' resolves with { data, status, headers }.
features
featuresobjectOptional generators.
features.queryboolean | object· defaultfalseGenerate TanStack Query v5 hooks and option factories for React, Vue, Svelte or Solid (true: React).
features.query.framework'react' | 'vue' | 'svelte' | 'solid'· default"react"TanStack Query adapter: 'react' (@tanstack/react-query 5), 'vue' (@tanstack/vue-query 5), 'svelte' (@tanstack/svelte-query 6) or 'solid' (@tanstack/solid-query 5).
features.query.queryMethods('get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace' | 'query')[]· default["get","query"]HTTP methods that produce query hooks; all others produce mutation hooks.
features.query.infiniteRecord<string, object>Infinite query hooks, keyed by operation name or
operationId.features.query.invalidatesRecord<string, string[]>Queries to invalidate after a successful mutation, keyed by mutation name or
operationId. Values are operation names,operationIds or tags.features.reactQueryboolean | object· defaultfalseAlias of
querywith framework 'react'. Use one or the other.features.reactQuery.queryMethods('get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace' | 'query')[]· default["get","query"]HTTP methods that produce query hooks; all others produce mutation hooks.
features.reactQuery.infiniteRecord<string, object>Infinite query hooks, keyed by operation name or
operationId.features.reactQuery.invalidatesRecord<string, string[]>Queries to invalidate after a successful mutation, keyed by mutation name or
operationId. Values are operation names,operationIds or tags.features.swrboolean | object· defaultfalseGenerate SWR hooks (useSWR, useSWRMutation, useSWRInfinite).
features.swr.queryMethods('get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace' | 'query')[]· default["get","query"]HTTP methods that produce query hooks; all others produce mutation hooks.
features.swr.infiniteRecord<string, object>Infinite query hooks, keyed by operation name or
operationId.features.swr.invalidatesRecord<string, string[]>Queries to invalidate after a successful mutation, keyed by mutation name or
operationId. Values are operation names,operationIds or tags.features.jsdocboolean· defaulttrueGenerate documentation comments.
features.validationfalse | 'zod' | 'valibot' | 'arktype' | object· defaultfalseGenerate schemas with Zod 4, Valibot 1 or ArkType 2 and validate at runtime.
features.validation.libraryrequired'zod' | 'valibot' | 'arktype'Schema library: 'zod' (4), 'valibot' (1) or 'arktype' (2).
features.validation.responseboolean· defaulttrueValidate response bodies.
features.validation.requestboolean· defaultfalseValidate request bodies before sending.
naming
namingobjectNaming conventions.
naming.operations'camelCase' | 'PascalCase' | 'snake_case' | 'preserve'· default"camelCase"Operation function names.
naming.models'camelCase' | 'PascalCase' | 'snake_case' | 'preserve'· default"PascalCase"Model type names.
naming.files'kebab-case' | 'camelCase' | 'PascalCase' | 'snake_case'· default"kebab-case"File names.
naming.parameters'preserve' | 'camelCase'· default"preserve"Parameter property names: wire names ('preserve') or camelCase identifiers.
naming.inputSuffixstring· default"Input"· not emptySuffix of request-side model variants created when models have readOnly or writeOnly properties.
types
typesobjectHow schemas map to types.
types.enums'union' | 'const'· default"union"'union' emits literal unions; 'const' also emits a frozen object per named enum.
types.readonlyPropertiesboolean· defaulttrueMark readOnly properties with the readonly modifier.
types.readWrite'split' | 'merged'· default"split"'split' leaves readOnly properties out of request types and writeOnly properties out of response types; 'merged' uses one type for both.
types.dates'string' | 'Date'· default"string"Type
dateanddate-timestrings as 'string', or as 'Date' with responses converted at runtime.
dashboard
dashboardobjectOptions of
swaggerz dashboard.dashboard.hoststring· default"127.0.0.1"· not emptyInterface to listen on.
dashboard.portnumber· default4400· ≥ 0, ≤ 65535, integerPort (0 picks one).
dashboard.allowNetworkAccessboolean· defaultfalseRequired to listen on a non-loopback interface.
dashboard.usageobjectUsage scanning of your source code.
dashboard.usage.includestring[]· default["src"]Files or directories to scan.
dashboard.usage.excludestring[]Path segments to skip.
lint
lintobjectOptions of
swaggerz lint.lint.rulesRecord<string, 'off' | 'info' | 'warning' | 'error'>Severity per lint rule ('off', 'info', 'warning' or 'error'), e.g. { 'operation-id': 'error' }.
plugins
plugins(string | [string, unknown?])[]Plugins, run in order within their enforce group. In JSON and YAML configs, reference modules by path or package name.
hooks
hookscode onlyInlineHooksPlugin hooks given inline, without writing a plugin. They run like a plugin named
config.hooks, after the default plugin group.hooks.beforeParsecode onlyfunctionThe
beforeParsehook (see the plugin hooks).hooks.afterNormalizecode onlyfunctionThe
afterNormalizehook (see the plugin hooks).hooks.operationNamecode onlyfunctionThe
operationNamehook (see the plugin hooks).hooks.modelNamecode onlyfunctionThe
modelNamehook (see the plugin hooks).hooks.jsdoccode onlyfunctionThe
jsdochook (see the plugin hooks).hooks.queryKeycode onlyfunctionThe
queryKeyhook (see the plugin hooks).hooks.resolveImportcode onlyfunctionThe
resolveImporthook (see the plugin hooks).hooks.beforeGeneratecode onlyfunctionThe
beforeGeneratehook (see the plugin hooks).hooks.generatecode onlyfunctionThe
generatehook (see the plugin hooks).hooks.transformFilecode onlyfunctionThe
transformFilehook (see the plugin hooks).hooks.afterGeneratecode onlyfunctionThe
afterGeneratehook (see the plugin hooks).hooks.beforeWritecode onlyfunctionThe
beforeWritehook (see the plugin hooks).hooks.afterWritecode onlyfunctionThe
afterWritehook (see the plugin hooks).
Environment variables
Environment variables override the config file, and command-line flags override both. The prefix is SWAGGERZ_.
| Variable | Overrides |
|---|---|
SWAGGERZ_SPEC_INPUT | spec.input |
SWAGGERZ_SPEC_VERSION | spec.version |
SWAGGERZ_OUTPUT_DIRECTORY | output.directory |
SWAGGERZ_OUTPUT_LANGUAGE | output.language |
SWAGGERZ_CLIENT_ADAPTER | client.adapter |
SWAGGERZ_CLIENT_BASE_URL | client.baseUrl |