swagger-api / swagger-api/swagger-ui
Could not resolve reference to a schema that certainly exists
@tim-lai is already working on this.
Since Apr 28, 2020.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A
- OS: MacOS
- Browser: chrome
- Version: Version 80.0.3987.116 (Official Build) (64-bit)
- Method of installation: npm
- Swagger-UI version: 3.25.0
- Swagger/OpenAPI version: OpenAPI 3.0.3
Content & configuration
I have set up a scenario demonstrating the bug within a CodeSandbox here: https://codesandbox.io/s/infallible-chandrasekhar-bw7x8
Describe the bug you're encountering
The scenario is a bit nuanced. The gist of it is that I get an error message from Swagger UI that an internal reference to a schema cannot be resolved, which is wrong because that schema certainly exists. This reference issue only occurs in a very specific scenario and the best way to understand it is to explore public/open/spec.yml within the code sandbox I've provided.
Screenshot below of the error, and here is the text of the error message:
Resolver error at paths./foo.get.responses.200.content.application/json.schema.properties.propB2.properties.propC.properties.propD.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/D does not exist in document
To reproduce...
Steps to reproduce the behavior:
- Load the application
- See error
- Comment out parameter
$refon line 11 ofpublic/openapi/spec.yml - See no error
- Uncomment default response schema
$refon lines 23-27 ofpublic/openapi/spec.yml - See error again
Expected behavior
None of these usages of references should cause an error.
Screenshots

Additional context or thoughts
I will add that the scenario that causes this issue to occur is extremely nuanced. To understand the better what causes this: follow from spec.yml#/components/schemas/A all the way to other-other-spec.yml#/components/schemas/D. The presence of both propB1 and propB2 and them referencing the same exact schema, other-spec.yml#/components/schemas/B is significant, as after removing one, the error does not occur.
Also, I discovered a temporary workaround for my specifications by making the internal reference within other-other-spec.yml include the file name. That workaround can be activated by uncommenting line 20 of other-other-spec.yml and commenting line 22. Of course, this shouldn't need to be done, as an internal reference is valid according to the specifications, but for now, I'm using that to be able to move on.
Any help on this issue would be great! I'm not familiar with the internals of swagger-ui-react, so I can't speculate too accurately on what the solution might be. Let me know if any clarifications are needed here.
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.
Assessment
This issue has not been assessed yet.