redocly-cli
redocly-cli copied to clipboard
Percent encoding in $ref URIs
Describe the bug
The split and bundle commands do not handle URI encoding $refs.
We used the split command on an OpenAPI spec and ended up with file such as ./paths/users_{id}.yaml. The $ref to each of those paths from the top-level file look like this:
paths:
/users/{id}:
$ref: paths/users_{id}.yaml
According to the spec, $ref should contain a URI, which does not permit { or } in the path - those characters should be percent-encoded.
Updating the $ref values to be percent-encoded (e.g. paths/users_%7Bid%7D.yaml) produces an error when using the bundler like the following:
Can't resolve $ref: ENOENT: no such file or directory, open '/example/openapi/paths/users_%7Bid%7D.yaml'
Expected behavior
The split command produces valid RFC3986 URIs, and the bundle command resolves $refs with percent-encoded paths.
Using OpenAPI 3+. Redocly Version(s) 1.0.0-beta.111
Node.js Version(s)
v19.5.0
#685 is tangentially related to this.
Hi @mfulgo. Thanks for the reporting
I think this discussion is connected: https://github.com/OAI/moonwalk/discussions/59