redocly-cli
redocly-cli copied to clipboard
`join` command regression: decorators/preprocessor are always executed
Describe the bug
Before this commit, the join command wasn't bundling documents. By changing this behaviour, running a join now always execute the decorators/preprocessor.
For us, it's a regression because we use decorators to remove internal documentation. So with the latest versions, we have no way to join ours different api files and keep the internal documentation conditionally.
To Reproduce Steps to reproduce the behavior:
openapi join file1.yaml file2.yaml
Expected behavior
It was expected that bundling wasn't part of the join command. From my understand, the bundling mechanism was only to resolve reference properly in the join command. Perhaps the join command could ignore the decorators/preprocessor from the config or we could support similar bundle parameters such as --skip-decorators
Logs If applicable, add logs to help explain your problem.
OpenAPI definition
.redocly.yaml:
lint:
extends:
- minimal
plugins:
- './build/openapi-plugins/decorators.js'
decorators:
cleanup/remove-hidden: error
cleanup/remove-internal: error
openapi-cli
Version(s)
beta-94
Node.js
Version(s)
N/A -> Running in docker
Additional context Add any other context about the problem here.
That comment (with the bundling) was done to solve https://github.com/Redocly/openapi-cli/issues/339
There is a workaround you can do. In newer versions of OpenAPI-cli we support a new configuration file format.
apis:
other@internal:
root: ./other.yaml
example@internal:
root: ./openapi.yaml
example@external:
root: ./openapi.yaml
lint:
decorators:
cleanup/remove-hidden: error
cleanup/remove-internal: error
lint:
plugins:
- './build/openapi-plugins/decorators.js'
extends:
- minimal
In this case, you could use the @internal
API for the join and the @external
for some external documentation purpose.
Here is a lightweight example of using the same root file with different decorators:
https://github.com/redocly-demo/demo-remove-x-internal
Increasing the priority on this, unexpected processing of the API descriptions is not a good surprise to include with a join command, we should try to keep the commands as atomic as we can.
We can disable decorators and preprocessors by default in join
command and add options like --allow-decorators
and --allow-preprocessors
to enable them. Or don't we need these options?
@adamaltman @lornajane what do you think ?
I agree with this suggestion, when doing a join
I don't necessarily expect other steps to be performed. Since use --lint
, a single active verb as a switch to the bundle
command, we could extend that pattern here and have --decorate
and --preprocess
as the parameter names.