Skip to content

feat(payload-samples): keep int64 values intact in samples - #2844

Closed
ump45nose wants to merge 1 commit into
Redocly:mainfrom
ump45nose:contrib/support-64-bit-integers-in-sample-respon-530
Closed

ump45nose wants to merge 1 commit into
Redocly:mainfrom
ump45nose:contrib/support-64-bit-integers-in-sample-respon-530

Conversation

@ump45nose

Copy link
Copy Markdown

feat(payload-samples): keep int64 values intact in samples

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: #530

This pull request was prepared with the assistance of an AI coding agent and
has not yet been reviewed by a human.

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
@ump45nose
ump45nose requested a review from a team as a code owner October 4, 2026 21:38
@AlexVarchuk

Copy link
Copy Markdown
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 main and reopen, and we'll prioritize the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support 64-bit integers in sample responses

2 participants