Support command-specific preprocessor execution (lint vs bundle vs docs)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
Is your feature request related to a problem? Please describe.
As a user developing custom preprocessors for Redocly CLI, I need the ability to run preprocessors only for specific commands (e.g., only during lint, but not during bundle, preview-docs, or build-docs).
Currently, preprocessors defined in redocly.yaml run for all commands that support them. The only way to skip a preprocessor is using the --skip-preprocessor CLI flag, which requires:
- Remembering to add the flag to every command where you don't want the preprocessor
- Maintaining this across multiple npm scripts and CI/CD pipelines
- An opt-out approach instead of opt-in
Use case
I've created a custom preprocessor that filters/modifies schemas from specific paths (e.g., auto-generated files, external vendor schemas, legacy code). This preprocessing is useful only during linting because:
- During
bundle: I want the original schemas preserved in the bundled output - During
preview-docs/build-docs: I want the full documentation generated, not filtered content - During
lint: I want to skip validation for specific paths
Current workaround
# Must add --skip-preprocessor to every non-lint command
redocly lint # preprocessor runs
redocly bundle --skip-preprocessor=my-plugin/my-preprocessor
redocly preview-docs --skip-preprocessor=my-plugin/my-preprocessor
redocly build-docs --skip-preprocessor=my-plugin/my-preprocessor
This is error-prone and requires coordination across teams and CI/CD pipelines.
Describe the solution you'd like
I'd like to understand what options are available to solve this problem:
-
Is the current command already available in the preprocessor context? If so, documentation on how to access it would solve this issue.
-
If not available, could command context be added? For example:
export const myPreprocessor: Oas3Preprocessor = (options) => { return { Schema: { leave: (schema, ctx) => { // Check which command is running if (ctx.command !== 'lint') { return; // Skip for non-lint commands } // ... preprocessor logic } } }; }; -
Alternatively, could command-specific preprocessor configuration be added to
redocly.yaml? For example:preprocessors: my-plugin/my-preprocessor: pathPatterns: ['**/generated/**'] commands: ['lint'] # Only run for lint command
Describe alternatives you've considered
- CLI flags with npm scripts - Current workaround, but requires maintenance and is error-prone
- Separate config file for linting - Creates duplication and maintenance overhead
Thank you.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with redocly.yaml, the preprocessor context, and the lint, bundle, preview-docs, and build-docs command entry points. Compare how --skip-preprocessor is applied today; done means users can limit a preprocessor to selected commands without repeating flags, with the supported behavior documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100