Repository navigation
Conversation
pojoAdapter returned a fresh toValue() result, so the strategy cache keyed by the returned POJO never hit and every resolveSubtree call refracted and normalized the whole definition again.
Finomosec
requested review from
cka121,
glowcloud and
robert-hebel-sb
as code owners
November 26, 2026 13:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pojoAdapterstores the refracted element inresolveOpenAPI3{1,2}Strategy.cachekeyed byvalue, but then returns a secondtoValue(normalized)object. The resolve strategy therefore never hits that cache and refracts the whole definition again. Since #3575 the pre-normalization result is not cached per input either, so Swagger UI, which passes its memoizedspecJS()toresolveSubtree, refracts, normalizes and serializes the entire definition on every operation expansion.This PR restores a per-input cache in
pojoAdapter(as in #3009 / #3281, now keyed by normalize function and input) and returns the cachedvalueobject, so the strategy cache hits.Motivation and Context
Refs swagger-api/swagger-ui#10748 (expanding operations is slow for OpenAPI 3.1, fast for 3.0.3).
With a 2.1 MB OpenAPI 3.1.0 definition (LiteLLM proxy, 1026 operations, 1062 schemas), expanding a single operation blocks the main thread for 6.6–7.4 s in swagger-ui 5.26.2. With this change it drops to 3.2–4.7 s, and to 1.7–2.3 s with swagger-ui 5.36.0 (long tasks measured in headless Chromium; the remaining time is the full-tree normalization after each resolve).
How Has This Been Tested?
test/resolver/strategies/openapi-3-1-apidomandopenapi-3-2-apidom: 64 tests pass. Lint and commitlint pass.test/client.jsandtest/oas3/client.js, which fail identically onmainin my environment (Node 23).Screenshots (if appropriate):
Types of changes
package.json)Checklist: