swagger-api / swagger-api/swagger-ui
Could not resolve reference when using reusable components
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: 138.0.7204.93
- Method of installation: npm
- Swagger-UI version: 5.17.1 and 5.27.0
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
You can find the definition here https://gist.github.com/rsedano/7055ec208474c8e7bd22c3a15ecf1391
Swagger-UI configuration options:
I use default configuration
SwaggerUI({
// your config options here
})
?yourQueryStringConfig
Describe the bug you're encountering
I am using Swagger-parser to bundle yaml files into a json. The json file that contains the OpenAPI definition of my API get generated correctly and I have validated it using different tools. The problem is when using swagger-ui, sometimes the schemas can not get resolved, the ref are not resolved and showing the following errors:
Could not resolve reference: Could not resolve pointer: /components/schemas/SwedishLoanRequestBody/properties/application/allOf/0 does not exist in document
I am using component that it should be possible to be reused, but swagger-ui not always render them. I have also reproduced the problem using "https://app.swaggerhub.com/" design tool.
To reproduce...
Steps to reproduce the behavior:
Using the following OpenAPI definition
Use swagger-ui-react v5.17.1 or v5.27.0
- Load the page that shows the swagger ui
- Drill down in Schemas
SwedishCreditCardRequestBody -> applicationandSwedishSalesFinanceRequestBody -> application - If the error occurs, you will not get the properties under "application" object
- See error: Could not resolve reference: Could not resolve pointer: /components/schemas/SwedishLoanRequestBody/properties/application/allOf/0 does not exist in document
If you don't get the error, try the steps above one more time. You might need to repeat it several times.
Expected behavior
No errors
Screenshots
From app.swaggerhub.com
From my own implementation of swagger-ui
Additional context or thoughts
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 with the linked OpenAPI gist and the swagger-ui-react v5.17.1/v5.27.0 entry point, then repeatedly open the SwedishCreditCardRequestBody and SwedishSalesFinanceRequestBody application schemas to reproduce the intermittent reference error. Compare the bundled definition with the rendered schemas; done means both application objects consistently show their properties without unresolved-reference errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100