swagger-api / swagger-api/swagger-ui

Performance drop when updating versions to OpenAPI 3.1.0

Open
#10,250 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: performance P2
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 (also Windows)
  • Browser: chromium (Brave - but any browser)
  • Version: 131.0.6778.69 (1.73.89)
  • Method of installation: npm
  • Swagger-UI version: 5.1.0 - 5.18.2
  • Swagger/OpenAPI version: OpenAPI 3.1.0
Content & configuration

Angular project using swagger-ui-dist:5.18.2

Example Swagger/OpenAPI definition:
N/A - large definition (11mb)

Swagger-UI configuration options:

import {SwaggerUIBundle} from 'swagger-ui-dist';

SwaggerUIBundle({
  spec: spec,
  domNode: this.swaggerEle.nativeElement,
  deepLinking: false,
  docExpansion: 'none',
  defaultModelExpandDepth: 3
})
Describe the bug you're encountering

UI performance issue when clicking on each endpoint and viewing its contents.

To reproduce...

Steps to reproduce the behavior:

  1. On Swagger UI
  2. Click to open a service
  3. Click to open an endpoint
  4. Loading icon hangs for ~6 seconds
Expected behavior

Endpoint information displays promptly without excessive delays.

Screenshots

Screenshot 2025-01-06 at 3 37 48 PM

Additional context or thoughts

Updating to swagger-ui-dist:5.18.2 (from 4.19.1) there is a UI performance issue when clicking on each endpoint and viewing its contents. Loading icon hangs for ~6 seconds, see screenshot. Once content loads, performance for that expansion is good. Issue persists on OpenAPI 3.1.0 spec but not OpenAPI spec < 3.1.0. I've reviewed a similar issue thread here: https://github.com/swagger-api/swagger-ui/issues/8606 - tested swapping our spec for twitter's (https://gist.github.com/char0n/0623cf602c23de8628b7e06012cfbf00) but issue still persists. We've tested swagger-ui-dist versions between 5.1.0 to 5.18.2 and the performance seems to degrade as the version increases. Oddly enough, as a workaround, we've discovered by manually overriding the 'openapi' value within the spec before initializing, the performance issued is resolved and the UI operates as expected.

Eg.

SwaggerUIBundle({
  spec: {
  	...spec,
  	openapi: '3.0.3'
  },
  domNode: this.swaggerEle.nativeElement,
  deepLinking: false,
  docExpansion: 'none',
  defaultModelExpandDepth: 3
})

Is there some configuration flag to handle this performance issue? Are there unforeseen consequences for overriding the openapi version?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. First reproduce the delay with the reported 11 MB OpenAPI 3.1.0 definition, then compare swagger-ui-dist versions 4.19.1 through 5.18.2 and the OpenAPI 3.0.3 workaround. Done means identifying the regression or relevant configuration behavior and restoring prompt endpoint expansion without changing the specification version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.