redocly-cli
redocly-cli copied to clipboard
Apply the closest redocly.yaml config to API docs
Is your feature request related to a problem? Please describe.
Currently, the config from the folder where the Redocly CLI is executed is used. This makes configuration more difficult, as users must either maintain separate config files for different API definitions and use the --config option (so they won't be applied automatically), or configure the apis section to apply rules or decorators differently for different files.
Describe the solution you'd like
A potential solution is to use the nearest redocly.yaml config when running a command like lint or bundle on a specific API file.
TBD: this changes how we treat config itself, and potentially the lint-ignore file. Main questions:
- [ ] can we drop the
apissection (since there will be no longer the 'main' config file)? (potentially, we can read and applyapisonly when explicitly setting--config) - [ ] performance issues
- [ ] how to save the lint-ignore files?
- [x] how would it work for the
joincommand? do we need a common config for this kind of commands? - [ ] how to resolve config with the
--configoption set? should it simply override other config files?
Describe alternatives you've considered
Using current resolution method. The VS Code extension resolution method could be updated independently and Realm already resolves config independently.
Additional context
Originally came from the VS Code extension.
This could also be aligned with how Realm resolves config (see this comment).
As a part of this issue, we can stop supporting any default config file names other than redocly.yaml.
@RomanHotsiy please evaluate the pitfalls and tradeoffs.
At this point, after discussion with @RomanHotsiy, we decided to continue going with the root-level config for Redocly CLI. Other products may resolve config separately. One possible option is to implement an alternative config resolution mechanism under a flag and potentially make it default in the next major version.