Misleading example value in case of cyclic references
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: 135.0.7049.114
- Method of installation: npm
- Swagger-UI version: 5.20.5
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Example Swagger/OpenAPI definition:
{
"swagger": "2.0",
"paths": {
"/A": {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/A"
}
}
}
}
}
},
"definitions": {
"A": {
"type": "object",
"properties": {
"nextA": {
"$ref": "#/definitions/A"
}
}
}
}
}
Swagger-UI configuration options:
SwaggerUI({
spec: apiSpec,
dom_id: '#api-ui-container',
defaultModelRendering: 'model',
showExtensions: true,
deepLinking: true,
plugins: [DisableTryItOutPlugin],
});
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior: Go to Example value of the only endpoint. You will see that it is:
{
"nextA": "string"
}
Although the nextA is really an object that follows the same definition, like in
{
"nextA": {
"nextA": {}
}
}
Of course in any given value the nextAs must stop at some recursion level, therefore the Swagger UI would have to decide how many levels to include in the example value. But showing a "string" instead is misleading.
Expected behavior
Even an empty object would make more sense. Please display something better than just a string.
Hey there @whoareyoukid 👋 Thanks for finding this bug! Are you interested in preparing PR with proposed solution? 🥺
@robert-hebel-sb Can I work on this issue?
@DipakHalkude Sure thing!
Thanks for finding time to help us out 🙏 Looking forward to PR 👀
I am on it :)