Add resolveSubtreeOnExpand option to skip subtree resolution on expand#10918
Open
paulwellnerbou wants to merge 4 commits into
Open
Add resolveSubtreeOnExpand option to skip subtree resolution on expand#10918paulwellnerbou wants to merge 4 commits into
paulwellnerbou wants to merge 4 commits into
Conversation
…ution on expand Adds an opt-in resolveSubtreeOnExpand config option (default true, preserving current behavior). When set to false, operation and model subtrees are no longer resolved when expanded and render directly from the unresolved spec, avoiding the browser tab freeze/crash on documents with many deeply nested oneOf compositions. To keep the unresolved view readable, models derive their display name from $ref/composition when no explicit name is present. Addresses swagger-api#10917
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
Adds a new
resolveSubtreeOnExpandconfiguration option (defaulttrue, preserving current behavior). When set tofalse, Swagger UI no longer resolves an operation's or model's subtree when it is expanded, and renders directly from the unresolved spec instead.Resolving a subtree dereferences every
$ref, merges compositions, and generates samples. For documents with many deeply nestedoneOfcompositions, doing this work on expand can freeze and eventually crash the browser tab (#10917). SettingresolveSubtreeOnExpand: falseskips it, keeping expansion responsive — at the cost of rendering the unresolved schema ($refs are shown by name). To keep that view readable, models now derive their display name from$ref/composition when no explicit name is present.Motivation and Context
Fixes #10917. Some valid OpenAPI documents — particularly those built from many nested
oneOfschemas — freeze and crash the browser tab when an affected operation is expanded, because expansion triggers full subtree resolution and sample generation. This option lets such documents opt out of resolution-on-expand and stay responsive.The default is unchanged (
true), so this is a non-breaking, opt-in change.How Has This Been Tested?
resolveSubtreeOnExpand=false.json-schema-5model components.oneOfcompositions, deployed for side-by-side comparison:resolveSubtreeOnExpand: false): https://wbou.dev/swagger-ui/performance-improvements/GET /v1/resource007. The "before" deployment freezes/crashes; the "after" one stays responsive.Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
docs/usage/configuration.md).Automated tests