Skip to content

Misleading example value in case of cyclic references #10524

@whoareyoukid

Description

@whoareyoukid

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.

Image

Expected behavior

Even an empty object would make more sense. Please display something better than just a string.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions