$ref recursive/indefinite resolving for examples
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
If
- examples (in our case for responses) are added from a separate file with e.g.
example: $ref: '../../dir/otherdir/example.data.get.json' - and those example responses themselves contain a
$reflike{ "field": { "$ref": "https://www.some-url.dev/api/data?cursor=eyJvZmZzZXQiOjUwLCJsaW1pdCI6NTB9" } }
the bundle/lint also tries to resolve those references - which is basically wrong, as they are part of the response, not part of the spec!
In our case, with the pagination cursor being part of the response, that resulted in an (potentially indefinite) loop and the redocly-cli was requesting those API requests from our staging server, paginating over and over...
Note: using the configuration setting resolve.doNotResolveExamples: true does not help here, because it will then not embed our example response into the bundled file, because it resolves not even the first encountered $ref, wich is referring to our local example file.
Expected behavior
If a $ref in an example json file is encountered, do not try to resolve it.
Or: add a configuration like doNotRecursivelyResolveExamples or config something like recursiveExampleResolvingDepth: 1 to prevent that behaviour.
Additional context
Redocly cli version used: 1.0.0-beta.126
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 tracing how bundling and linting handle the local example reference and then nested $ref values in the example response. Compare this behavior with resolve.doNotResolveExamples and verify that the local example is embedded while nested response references are left untouched, without repeated requests or recursion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100