redocly-cli
redocly-cli copied to clipboard
Bundle command does not replace self-referencing files.
Describe the bug When a file references itself, the references are not substituted with local refs.
To Reproduce Steps to reproduce the behavior:
- Given an empty config
- And this OpenAPI file(s) test-api.json
- Run this command with these arguments...
redocly bundle test-api.json -o test-api-bundled.json - Notice that the bundled OpenAPI still has an "external" format reference:
"$ref": "test-api.json#/parameters/myParam"
Expected behavior
"$ref": "test-api.json#/parameters/myParam" should be replaced by "$ref": "#/parameters/myParam".
Logs
OpenAPI description Faced with Microsoft-Azure swagger specifications but for simplicity, linked a minimal example to showcase the issue. Haven't tested yet with OpenAPI V3, but expected the same behavior.
Redocly Version(s) 1.16.0
Node.js Version(s)
18.18.2
Additional context
Clearly, the Swagger could be written differently and also, we could patch it, but still, after a bundle, if successful, you would expected no more external reference format in any reference.
By the way, issue was noticed first when using @redocly/openapi-core but reproduced with the CLI.
Thanks for reporting! BTW, does dereferenced bundling work around your issue?
Thanks for the quick reply. --dereferenced does workaround the issue, but still not the best option as some of the APIs we handle may contain "cycles", we usually dereference "lazily" to avoid infinite loops. Also the size of the API might get too bigger.
Yes, I think that makes sense.