fix(plugin-zod): coerce bigint so int64 responses validate - #797
Merged
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: bd19587 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@kubb/plugin-axios
@kubb/plugin-cypress
@kubb/plugin-faker
@kubb/plugin-fetch
@kubb/plugin-mcp
@kubb/plugin-msw
@kubb/plugin-react-query
@kubb/plugin-redoc
@kubb/plugin-swr
@kubb/plugin-ts
@kubb/plugin-vue-query
@kubb/plugin-zod
commit: |
Contributor
|
Size Change: 0 B Total Size: 311 kB ℹ️ View Unchanged
|
4 tasks
`format: int64` printed `z.bigint()`, but `JSON.parse` hands back a
`number`, so every response containing such a field failed validation
under `pluginFetch({ validator: 'zod' })`.
Both printers now emit `z.coerce.bigint()`, unconditionally and in both
directions, so no `InputSchema` variant is generated. Precision past
2^53-1 is already gone by the time Zod runs, which the existing
`integerType: 'number'` workaround does not change either.
Closes #786
stijnvanhulle
force-pushed
the
fix/int64-coerce-bigint
branch
from
August 27, 2026 09:50
6d03220 to
4f97e63
Compare
…s-797 chore: update generated examples
4 tasks
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.
🎯 Changes
Closes #786.
format: int64printedz.bigint().JSON.parsehands back anumberfor those fields, soz.bigint()rejected every response containing one when usingpluginFetch({ validator: 'zod' }). The default config of plugin-zod and plugin-fetch could not work together.Both Zod printers now emit
z.coerce.bigint():Notes for review
encodeanddecode, so no${name}InputSchemavariant is generated for components carrying an int64.coercionoption no longer gates bigint.coercion: { numbers: true }producedz.coerce.bigint()before and still does, so that path is unchanged. The JSDoc onOptions.coercionrecords the new behavior.42 → 42n, an existingbigintpasses through, and a non-integer like1.5is still rejected.JSON.parse, before Zod runs. Fixing that needs a precision-preserving parser in plugin-fetch and is out of scope here. TheintegerType: 'number'workaround has the same limit.✅ Checklist
pnpm run test.🚀 Release Impact