Percent encoding in $ref URIs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the split and bundle commands using an OpenAPI 3+ document containing a path such as /users/{id}. Trace how split writes the $ref path and how bundle resolves percent-encoded paths; done means split emits valid percent-encoded URIs and bundle resolves those references successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100