-
Notifications
You must be signed in to change notification settings - Fork 201
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-preprocessorThis 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.