swagger-api / swagger-api/swagger-ui
🐛 Deep linking broken in swagger-ui-react since v5.17.14
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Description
Deep linking stopped working in swagger-ui-react starting from v5.17.14. The deepLinking prop has no effect — navigating directly to a URL fragment (e.g. #/pet/getPetById) no longer expands or scrolls to the target operation. The same setup works correctly on v5.17.13.
Affected versions
| Version | Deep linking works? |
|---|---|
| 5.17.13 | ✅ Yes |
| 5.17.14 | ❌ No |
| latest | ❌ No |
Reproduction
Minimal reproduction using Vite + React:
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<SwaggerUI url="https://petstore.swagger.io/v2/swagger.json" deepLinking />
</StrictMode>
);
Steps to reproduce:
- Install
swagger-ui-react@5.17.13and run the app — navigate to a URL likehttp://localhost:5173/#/pet/getPetById. The operation expands correctly. ✅ - Upgrade to
swagger-ui-react@5.17.14(or later) and repeat — the fragment is ignored and nothing expands. ❌
Root cause (suspected)
This appears to have been introduced by commit 8aa5292 (fix(system): remediate component wrapping functionality, released in v5.17.14), which changed a single line in src/core/system.js:
- .reduce(systemExtend, { components: { ...toolbox.getComponents() } })
+ .reduce(systemExtend, { components: toolbox.getComponents() })
Removing the spread means the initial accumulator now holds a direct reference to the live components map rather than a shallow copy. Subsequent systemExtend calls mutate this shared object, which appears to corrupt the component registry relied upon by the deep-linking plugin to resolve and expand the target operation on initial render.
Expected behaviour
Navigating to a URL with a valid fragment (e.g. #/pet/getPetById) should expand the corresponding operation, consistent with behaviour prior to v5.17.14.
Actual behaviour
The fragment is silently ignored. No operation is expanded and no console error is thrown.
Environment
swagger-ui-react: 5.17.14+- React: 18 / 19
- Browser: Chrome 124, Firefox 126 (reproducible in both)
StrictMode: yes (also reproducible without)
References
- Diff between v5.17.13 and v5.17.14: https://github.com/swagger-api/swagger-ui/compare/v5.17.13...v5.17.14
- Suspected regression commit: https://github.com/swagger-api/swagger-ui/commit/8aa529201395224707ab00bb4b6ce71e41d082a4
- Original issue that commit referenced: #9919
Workaround
Pin to swagger-ui-react@5.17.13 until a fix is released.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/core/system.js and compare the accumulator change from commit 8aa5292 between v5.17.13 and v5.17.14. Reproduce the issue with the provided Vite + React example and the #/pet/getPetById fragment, then trace how the component registry is used during initial deep-link handling. Done means valid fragments expand and scroll to their operations again without breaking the v5.17.14 component-wrapping fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100