Skip to content

Response model expand/collapse does not work on initial render with OAS 3.1 #10628

Closed

Description

@scottohara

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Version: 142
  • Method of installation: npm
  • Swagger-UI version: 5.30.2
  • Swagger/OpenAPI version: OpenAPI 3.1

Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.1.0",
  "info": {
    "version": "1.0.0",
    "title": "Swagger Petstore",
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "servers": [
    {
      "url": "http://petstore.swagger.io/v1"
    }
  ],
  "paths": {
    "/pets": {
      "get": {
        "summary": "List all pets",
        "operationId": "listPets",
        "tags": ["pets"],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "How many items to return at one time (max 100)",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A paged array of pets",
            "headers": {
              "x-next": {
                "description": "A link to the next page of responses",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pets"
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
		}
  },
  "components": {
    "schemas": {
      "Pet": {
        "type": "object",
        "required": ["id", "name"],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "tag": {
            "type": "string"
          }
        }
      },
      "Pets": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/Pet"
        }
      },
      "Error": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}

Swagger-UI configuration options:

SwaggerUI({
  defaultModelRendering: "model"
})

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. Render any Open API 3.1 spec with defaultModelRendering: "model" configuration
  2. Click on an operation to expand it and show the Responses section
  3. In the "Schema" section, click on any part of the model that should expand/collapse
  4. Observe that clicking does nothing
  5. Click "Example Value" to toggle to the example view
  6. Click "Schema" to toggle back to the schema view
  7. Observe that expanding/collapsing the model now works

Expected behavior

When the "Schema" view is rendered by default (defaultModelRendering: "model"), the expand/collapse should work

Additional context or thoughts

The bug only seems to present itself when using OAS 3.1. Using OAS 3.0 or earlier does not exhibit the same problem.

I suspect that the problem could be here:

useEffect(() => {
pathMutator(
parentState === JSONSchemaIsExpandedState.DeeplyExpanded
? JSONSchemaIsExpandedState.DeeplyExpanded
: isExpandedState
)
}, [parentState])

This effect depends on pathMutator, parentState and isExpandedState, but the dependencies array only includes [parentState]. This means that the initial value of isExpandedState is captured when the effect runs on initial render, but the effect won't re-run if that value later changes.

Activity

  1. scottohara commented on Mar 31, 2026

    @scottohara
    ContributorAuthor

    Confirming that this is still an issue in Swagger UI v5.32.1 (see the steps above, it should be reasonably trivial for anyone to reproduce).

    The linked PR #10639 addresses the bug, but has been awaiting review for some time.

    Would greatly appreciate any maintainer who can spare some time to review and approve this PR. Thanks in advance.

  2. scottohara commented on Jun 1, 2026

    @scottohara
    ContributorAuthor

    Confirming that this is still an issue in Swagger UI v5.32.6 (see the steps above, it should be reasonably trivial for anyone to reproduce).

    The linked PR #10639 addresses the bug, but has been awaiting review for some time.

    Would greatly appreciate any maintainer who can spare some time to review and approve this PR. Thanks in advance.

  3. alkismavridis commented on Jun 30, 2026

    @alkismavridis

    Also affected. The error happens randomly so the hypothesis of a race condition seems to be accurate. Do we have any news on the issue?

  4. alkismavridis commented on Jun 30, 2026

    @alkismavridis

    As a workaround, we click on "Example Value", then back on "Schema" and then it works.

    Image
  5. scottohara commented on Sep 14, 2026

    @scottohara
    ContributorAuthor

    It would appear that this issue can no longer be reproduced using the latest unreleased version in main.

    It seems that the work done for #11019 has also resolved this issue, and I would expect it to be fixed for users in the next release (whether that's v15.32.16 or v15.33.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions