Repository navigation
fix(theme): preserve large integer precision in response panel (#1208) - #1458
Merged
Merged
Conversation
The response pretty-printer round-tripped the body through JSON.parse/JSON.stringify, which silently truncated integers beyond Number.MAX_SAFE_INTEGER (e.g. 19-digit IDs like 1945044589271781376 became 1945044589271781400). Replace the round trip with a small string-level pretty-printer that re-indents structural tokens only, so number literals pass through verbatim. JSON.parse is kept solely as a validity check so malformed bodies still fall through to the XML/raw branch. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Size Change: 0 B Total Size: 2.29 MB ℹ️ View Unchanged
|
|
Visit the preview URL for this PR (updated for commit ec0ea49): (expires Wed, 13 May 2026 15:47:56 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
This branch was previously deployed
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.
Summary
Fixes #1208. The response pretty-printer round-tripped the body through
JSON.parse/JSON.stringify, which silently truncated integers beyondNumber.MAX_SAFE_INTEGER(e.g. the reported 19-digit ID1945044589271781376became1945044589271781400).This PR replaces the round trip with a small string-level pretty-printer that re-indents structural tokens only — number literals pass through verbatim, so any precision the upstream service emitted is preserved exactly.
JSON.parseis kept solely as a validity check so malformed bodies still fall through to the XML / raw branch.packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx).Test plan
yarn watch+yarn start, navigate to the demo's httpbin → POST /anything page.{"id": 1945044589271781376}and confirm the response panel shows"id": 1945044589271781376(not…1400).{"big": 9999999999999999, "neg": -9007199254740993, "sci": 1.10}and confirm each value is preserved verbatim.🤖 Generated with Claude Code