fix(oas3): scope callbacks expansion state by callback name#10887
Open
yogeshwaran-c wants to merge 1 commit into
Open
fix(oas3): scope callbacks expansion state by callback name#10887yogeshwaran-c wants to merge 1 commit into
yogeshwaran-c wants to merge 1 commit into
Conversation
Two callbacks declaring the same URL template path item (e.g. both
`myEvent` and `otherEvent` containing
`'{$request.body#/callbackUrl}': post:`) shared the same layout
isShownKey `["operations", "callbacks", operationId]`, because the
generated operationId is identical (path + method). Toggling expansion
on one callback flipped the shared key and expanded both blocks.
The DOM id derived from this key also collided, producing duplicate
ids in the rendered page.
Fix: pass a per-callback tag (`callbacks-<callbackName>`) so each
callback gets its own isShownKey and DOM id.
Fixes swagger-api#5536
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
When an OAS3 operation declares multiple callbacks that share the same URL template path item (e.g. both
myEventandotherEventcontaining'{$request.body#/callbackUrl}': post:), the rendered UI fails to let the user expand one callback box independently. Clicking the expand control on one callback toggles both, and the two callback operation blocks render with the same DOM id.Root cause
OperationContainer.mapStateToPropsderives the layout isShownKey as["operations", tag, operationId]. For callbacks rendered bysrc/core/plugins/oas3/components/callbacks.jsx, every nestedOperationContainerwas passedtag="callbacks". When two callbacks have the same path and method, swagger-client'sopIdhelper (in the absence of an explicitoperationId) produces the same string from path + method, so both containers share the exact same isShownKey. Toggling one flips the single Redux flag, expanding both, and the DOM id derived from that key (inoperation.jsx) also collides.Fix
Pass a per-callback tag —
`callbacks-${callbackName}`— so each callback block gets a unique isShownKey and unique DOM id, while still being clearly namespaced under callbacks.Motivation and Context
Fixes #5536
How Has This Been Tested?
test/unit/core/plugins/oas3/callbacks.jsxOperationContaineris rendered per callback path-item operation.tagprop is`callbacks-${callbackName}`and unique across colliding URLs.[\"callbacks\", \"callbacks\"]) and passes with the fix.test/e2e-cypress/e2e/bugs/5536.cy.jswith fixturetest/e2e-cypress/static/documents/bugs/5536.yaml(the exact spec from the issue, with an explicitoperationIdon the parent only).#operations-callbacks-myEvent-...and#operations-callbacks-otherEvent-...DOM ids exist.myEventand assertsmyEventbecomes.is-openwhileotherEventdoes not.Checklist