swagger-api / swagger-api/swagger-ui
Rendering of references to properties depends on the order of clicks in the UI
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: macOS
- Browser: chrome
- Version: 136
- Method of installation: npm
- Swagger-UI version: 5.21.0
- Swagger/OpenAPI version: 3.0
Content & configuration
I have a minimal spec to reproduce this behaviour. The spec contains a schema (Test) that is referencing another schema (TestRef). TestRef contains two properties; value which is just a simple type and valueRef which is referencing value.
Based on the order in which I expand the schemas in the UI, the UI produces different results.
I noticed this behaviour when using the swagger-ui-react library, but it can also be observed on https://editor.swagger.io and https://editor-next.swagger.io/.
Example Swagger/OpenAPI definition:
openapi: 3.0.4
info:
version: 0.0.1
title: Test
description: Test
paths: {}
components:
schemas:
Test:
$ref: "#/components/schemas/TestRef"
TestRef:
type: object
properties:
value:
type: number
valueRef:
$ref: "#/components/schemas/TestRef/properties/value"
Swagger-UI configuration options:
SwaggerUI({
spec=`<insert spec from above>`
})
Describe the bug you're encountering
When clicking on Test, the value property is rendered correctly as a number. But the valueRef property is not rendered as a number but instead just displays the reference, e.g. https://editor.swagger.io/#/components/schemas/TestRef/properties/value.
When instead clicking on TestRef and then clicking on Test, both properties are correctly rendered as number.
To reproduce...
Steps to reproduce the behavior:
- Go to https://editor.swagger.io
- Insert the example spec from above
- Reload the page
- Click on the schema
Test - Observe how
valueRefis not rendered as anumber - Reload the page
- Click on the schema
TestRef - Click on the schema
Test - Observe how
valueRefin rendered properly
Expected behavior
The behaviour of how refs are rendered should not depend on the order of clicks in the UI.
Screenshots
Behavior when clicking Test:
Behavior when clicking TestRef and then Test:
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 minimal OpenAPI definition in the issue and reproduce the schema rendering sequence in Swagger UI: open Test first, then reload and open TestRef before Test. Trace how the UI resolves the property reference and add a regression check covering both click orders. Done means valueRef renders as number consistently rather than displaying the reference URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100