Redocly / redocly-cli

⚒️ Redocly CLI makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more.
https://redocly.com/docs/cli/
MIT License
920 stars 140 forks source link

Percent encoding in $ref URIs #1086

Open mfulgo opened 1 year ago

mfulgo commented 1 year ago

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 commented 1 year ago

685 is tangentially related to this.

IgorKarpiuk commented 1 year ago

Hi @mfulgo. Thanks for the reporting

adamaltman commented 1 year ago

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