swagger-api / swagger-api/swagger-ui
Issue rendering correct schemas in OAS 3.1.x with multiple Swagger UI instances on a page
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: 133
- Method of installation: npm
- Swagger-UI version: 5.20.0
- Swagger/OpenAPI version: OpenAPI 3.1.x
Content & configuration
2 x example OpenAPI definitions:
openapi: 3.1.1
info:
title: Spec 1
paths:
/test:
get:
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/TestModel'
components:
schemas:
TestModel:
properties:
test:
type: string
type: object
openapi: 3.1.1
info:
title: Spec 2
paths:
/test2:
get:
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/TestModel2'
components:
schemas:
TestModel2:
properties:
test2:
type: string
type: object
Swagger-UI configuration options:
SwaggerUI({
dom_id: "#spec1",
spec: // from spec 1 above
});
SwaggerUI({
dom_id: "#spec2",
spec: // from spec 2 above
});
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior:
- Create a page that renders two
SwaggerUI()instances as per the above configuration - Observe that the "Schemas" for both instances shows the
TestModel(defined in spec 1) - Observe that expanding the
TestModelin the second instance also expands the one in the first instance - Edit either spec (or both specs) and change the version to
openapi: 3.0.4 - Observe that the "Schemas" are now correct for both instances
Expected behavior
When using OAS 3.1.x, the first component instance should show TestModel as defined in spec 1.
When using OAS 3.1.x, the second component instance should show TestModel2 as defined in spec 2.
Screenshots
Example showing the same TestModel appearing for both component instances when the spec version is 3.1.1:
Example showing the correct models appearing when one of the specs is changed to version 3.0.4:
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 two SwaggerUI() instances using the two inline OpenAPI 3.1.1 definitions, then compare the behavior after changing both versions to 3.0.4. Trace the Schemas and TestModel/TestModel2 entry points in the rendered UI. Done means each instance displays and expands only its own schemas under OpenAPI 3.1.x.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100