feat (change-history): add sidebar with topbar toggle#10952
feat (change-history): add sidebar with topbar toggle#10952tunjiadeyemi wants to merge 3 commits into
Conversation
wbizmo
left a comment
There was a problem hiding this comment.
Went through this properly, checked out the branch and actually ran it, not just read the diff.
Big one: this reverts a same day bug fix
Earlier today master got a fix for a crash in getOAS3RequiredRequestBodyContentType, calling .entrySeq() on requestBody.getIn(["content"]) when a requestBody has no content field. Commit 832008a, PR #10837.
This branch was forked before that fix landed and never got rebased. So the diff here deletes the null check that fix added, and deletes all three tests that covered it (the describe("getOAS3RequiredRequestBodyContentType") block is gone from the test file).
I didn't just spot this, I reproduced it. Checked out the branch and ran the exact scenario the deleted test covered:
TypeError: Cannot read properties of undefined (reading 'entrySeq')
at getOAS3RequiredRequestBodyContentType (src/core/plugins/spec/selectors.js:549:33)
So merging this as is brings back a crash that was already fixed and shipped, and removes the regression test that would've caught it. This alone should block the PR no matter how good the feature itself is.
dist files are hand committed
The diff includes dist/swagger-ui.js and dist/swagger-ui.js.map, a full rebuilt minified bundle. That's normally generated at release time, not something committed by hand in a feature branch. Please pull these out, they're just adding noise on top of the actual problem above.
localStorage design needs a second look
The feature snapshots the full resolved spec into localStorage on every load, keyed by spec URL, capped at 20 history entries but not capped by size.
writeJson()has no try/catch aroundlocalStorage.setItem. A large spec or a quota exceeded/private browsing situation will throw uncaught during spec load.- Full spec content sits in localStorage with no expiry beyond a manual "clear history" click. For internal APIs that's spec content parked indefinitely on whatever machine opened the docs.
Not a blocker on its own but worth deciding on before this ships.
Bottom line
Rebase onto current master and confirm the crash fix survives, pull the dist files out of the diff, and wrap the localStorage write in a try/catch. Happy to take another look once that's done, the feature idea itself is solid, this is a branch hygiene problem more than a design problem.
|
@wbizmo awesome, i'll get to it, thanks! |
- harden localStorage writes and snapshot retention - catch quota/private-mode failures on setItem - cap full-spec snapshots by size (512KB) and TTL (30 days) so history data cannot grow or linger unbounded.
|
hey @wbizmo Addressed everything:
|
wbizmo
left a comment
There was a problem hiding this comment.
Went through this again properly, checked out the updated branch and re-ran everything rather than trusting the commit messages.
The rebase fixed the main issue, 832008a is now an actual ancestor of this branch, and I re-ran the crash scenario (requestBody with no content field), it resolves cleanly instead of throwing. Dist files are gone from the diff too.
The localStorage hardening in 4fd4a71 is solid: writeJson now catches setItem failures instead of throwing uncaught, and the size cap (512KB) plus 30-day TTL means history data can't grow or linger unbounded. That's a real fix, not just a try/catch slapped on top.
Ran the full suite: 885 tests, 873 passing, no regressions, nothing pre-existing broken.
Nice turnaround on all three points. No objections from me at this point.
Description
This PR adds an API Change History feature to Swagger UI so users can quickly see what changed between OpenAPI spec reloads.
Implemented:
Motivation and Context
When backend teams update the OpenAPI document, frontend/API consumers currently have no native way in Swagger UI to track what changed. They must manually compare specs.
This feature adds built-in change visibility by capturing snapshots and presenting a readable history timeline of changes after reloads.
Fixes #10951
How Has This Been Tested?
Manual testing:
Automated testing:
Result: all relevant tests passed
Screenshots (if appropriate):
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests