Post-Processor System#
The postProcess option in @hey-api/openapi-ts runs arbitrary shell commands on the generated output folder after all files have been written to disk. It is typically used to auto-format or auto-lint generated TypeScript files so the output is immediately clean.
postProcess lives under output in the config and accepts an array of preset strings, custom command objects, or a mix of both :
// output/types.ts
postProcess?: ReadonlyArray<PostProcessorPreset | UserPostProcessor>;
Commands execute sequentially in the order they are declared.
Note:
formatandlint(the legacy top-level output options) are deprecated in favor ofpostProcess.
Built-in Presets#
Seven presets are available as string literals. Their full command + args expansions are defined in packages/openapi-ts/src/config/output/postprocess.ts :
| Preset | Effective shell call |
|---|---|
'biome:check' | biome check --write {{path}} |
'biome:format' | biome format --write {{path}} |
'biome:lint' | biome lint --write {{path}} |
'eslint' | eslint {{path}} --fix |
'oxfmt' | oxfmt {{path}} |
'oxlint' | oxlint --fix {{path}} |
'prettier' | prettier --ignore-unknown {{path}} --write --ignore-path ./.prettierignore |
Custom Commands#
Pass a { command, args } object for any tool not in the preset list :
postProcess: [
{ command: 'dprint', args: ['fmt', '{{path}}'] },
]
The {{path}} token is replaced at runtime with the absolute path to output.path. Presets use this same mechanism internally.
You can mix presets and custom commands in one array:
postProcess: ['eslint', { command: 'prettier', args: ['{{path}}', '--write'] }]
Opting Out / Ignoring Files#
Add the output directory to the tool's standard ignore file (e.g., .eslintignore, .prettierignore) to skip processing specific paths without removing the processor from the config.
Execution Path in the Codebase#
Post-processing is triggered inside createClient after generateOutput completes and only when config.dryRun is false :
generateOutput(context) // write .ts files
→ postprocessOutput(config.output, postProcessors, jobPrefix) // run commands
The postProcessors map imported from ./config/output/postprocess resolves preset strings to their concrete { command, args } objects before execution. The actual postprocessOutput runtime is implemented in @hey-api/shared.
Key Source Files#
| File | Purpose |
|---|---|
src/config/output/postprocess.ts | Preset registry (postProcessors map) and PostProcessorPreset type |
src/config/output/types.ts | UserOutput.postProcess field declaration |
src/create-client.ts | Orchestrates generateOutput → postprocessOutput call |
| Output config docs | User-facing reference for all postProcess options |