Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance drop when updating versions to OpenAPI 3.1.0 #10250

Open
otionstem opened this issue Jan 6, 2025 · 2 comments
Open

Performance drop when updating versions to OpenAPI 3.1.0 #10250

otionstem opened this issue Jan 6, 2025 · 2 comments

Comments

@otionstem
Copy link

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: #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?

@char0n
Copy link
Member

char0n commented Jan 8, 2025

Hi @otionstem,

I'm not able to reproduce on https://gist.github.com/char0n/0623cf602c23de8628b7e06012cfbf00. You seem to be seeing the issue on twitter API as well - for me it's instant on https://petstore3.swagger.io/ (when loading the OpenAPI Description).

I think what we're seeing here is a described in #9513 (comment), section "Cycles (circular references)", but without testing on your actual definition it's impossible to tell. I can create a recipe for you using ApiDOM dereferencing and you can report back how long the dereferencing took. Would that work for you?

Attaching related issues:

@otionstem
Copy link
Author

I can create a recipe for you using ApiDOM dereferencing and you can report back how long the dereferencing took. Would that work for you?

Sure I'll give it a shot, thanks.

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

No branches or pull requests

3 participants