swagger-api / swagger-api/swagger-ui
Incorrect "Could not resolve reference" error displayed.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A
- OS: Windows 10
- Browser: chrome 121.0.6167.86
- Method of installation: Docker (https://hub.docker.com/r/swaggerapi/swagger-ui/tags)
- Swagger-UI version: 5.11.7
- Swagger/OpenAPI version: 3.1
Content & configuration
I've reduced my large multi-file spec down to the bare minimum that demonstrates this issue:
Save as swagger_test.yaml:
openapi: 3.0.3
info:
version: 1.0.0
title: Title
paths:
"/path1":
$ref: './swagger_test_path1.yaml#/paths/%2Fpath1'
"/path2":
$ref: './swagger_test_path2.yaml#/paths/%2Fpath2'
Save as swagger_test_path1.yaml:
openapi: 3.0.3
info:
version: 1.0.0
title: Title
paths:
"/path1":
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
rsp:
$ref: './swagger_test_schemas.yaml#/components/schemas/WSPath1Response'
responses:
204:
description: Success
Save as swagger_test_path2.yaml:
openapi: 3.0.3
info:
version: 1.0.0
title: Title
paths:
"/path2":
get:
responses:
200:
description: Success
content:
application/json:
schema:
type: object
properties:
result:
$ref: "#/components/schemas/WSResult"
delete:
responses:
200:
description: Success
content:
application/json:
schema:
type: object
properties:
result:
$ref: "#/components/schemas/WSResult"
components:
schemas:
WSResult:
type: object
properties:
details:
$ref: './swagger_test_schemas.yaml#/components/schemas/WSResultDetails'
Save as swagger_test_schemas.yaml:
openapi: 3.0.3
info:
version: 1.0.0
title: Title
paths: {}
components:
schemas:
WSBaseResultDetails:
type: object
properties:
info:
type: string
WSResultDetails:
allOf:
- $ref: "#/components/schemas/WSBaseResultDetails"
- type: object
properties:
status:
$ref: "#/components/schemas/WSStatus"
WSStatus:
type: object
properties:
text:
type: string
WSPath1Response:
type: object
properties:
data:
type: string
Describe the bug you're encountering
The spec renders correctly, but the above errors are reported.
Note that if I change the openapi version to 3.1, these errors are not displayed. However, the render time of my large multi-file spec is about 6 seconds when specifying openapi 3.0.3, but about 2.5 minutes when specifying openapi 3.1, so moving to 3.1 is not practical at this point.
To reproduce...
Open swagger_test.yaml defined above using swagger-ui 5.11.7
Expected behavior
References are resolved and spec is rendered correctly, so "Unresolved reference" errors should not be displayed.
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 loading swagger_test.yaml and its three referenced YAML files in Swagger UI 5.11.7 with OpenAPI 3.0.3, then compare the reported errors with the correctly rendered specification. Trace the reference-resolution path used for encoded path fragments and nested external references. Done means the specification renders without incorrect unresolved-reference errors while retaining the expected behavior for OpenAPI 3.1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100