Repository navigation
Conversation
JavaScript numbers are IEEE-754 doubles, so `JSON.parse` rounds away the low-order digits of any integer with more than 15-16 significant digits. An int64 value such as `10765432100123456789` was therefore shown as `10765432100123458000` in the response sample. External JSON examples are now parsed with a pass that rewrites integer literals a double cannot hold exactly into a `BigIntValue` that carries the digits from the source text, and the JSON viewer renders those digits as a number token. The wrapper also implements `toJSON`, so the copy button emits the exact digits instead of a silently rounded number, and the folding-button heuristic ignores it so it is not mistaken for a collapsible object. Values parsed elsewhere, for instance `example` inline in the spec, still arrive through `@redocly/openapi-core` before ReDoc sees them and are not covered. Closes: Redocly#530
Collaborator
|
@ump45nose Thank you for taking the time to contribute. We're sorry this didn't get the attention it deserved before Redoc v3.0.0 shipped. 馃檹 With the major changes in v3, we're closing PRs opened against the previous version. If this is still relevant, feel free to rebase onto |
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.
feat(payload-samples): keep int64 values intact in samples
JavaScript numbers are IEEE-754 doubles, so
JSON.parserounds away thelow-order digits of any integer with more than 15-16 significant digits.
An int64 value such as
10765432100123456789was therefore shown as10765432100123458000in the response sample.External JSON examples are now parsed with a pass that rewrites integer
literals a double cannot hold exactly into a
BigIntValuethat carries thedigits from the source text, and the JSON viewer renders those digits as a
number token. The wrapper also implements
toJSON, so the copy button emitsthe exact digits instead of a silently rounded number, and the folding-button
heuristic ignores it so it is not mistaken for a collapsible object.
Values parsed elsewhere, for instance
exampleinline in the spec, still arrivethrough
@redocly/openapi-corebefore ReDoc sees them and are not covered.Closes: #530