redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Percent encoding in $ref URIs

Open mfulgo opened this issue 1 year ago • 3 comments

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

mfulgo avatar May 16 '23 17:05 mfulgo

#685 is tangentially related to this.

mfulgo avatar May 16 '23 17:05 mfulgo

Hi @mfulgo. Thanks for the reporting

IgorKarpiuk avatar May 18 '23 08:05 IgorKarpiuk

I think this discussion is connected: https://github.com/OAI/moonwalk/discussions/59

adamaltman avatar Jun 13 '23 19:06 adamaltman