Conversation
This update adds support for Zod 4 while maintaining backwards compatibility with Zod 3. Key changes: - Update peerDependency to support both zod ^3.0.0 and ^4.0.0 - Create zod-compat.ts utility module to abstract internal Zod API differences - Update with-validation.ts to use compatibility helpers - Update vendored zod-openapi.ts and zod-to-ts.ts for Zod 4 - Update generate-openapi and generate-route-types for Zod 4 compatibility - Simplify type definitions to work with both Zod versions - Remove unused @anatine/zod-openapi dependency (code was already vendored) Breaking changes in Zod 4 that were addressed: - ._def moved to ._zod.def - ._def.typeName moved to ._zod.def.type - ZodEffects and ZodObject type signatures changed - Various class exports renamed or removed
…patibility Zod 4 has stricter type inference than Zod 3. The jsonResponse schema was defining todo as required, but the handler returns without todo when ok=false. This caused TypeScript errors with Zod 4's improved type inference. - Make todo optional in get.ts and index.ts response schemas - Remove .failing modifier from get-boolean test since it now passes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
In Zod 4, the shape property is accessed differently via the def object. Use the getShape helper from zod-compat instead of accessing .shape directly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update getEnumValues to handle Zod 4's different enum structure (uses schema.options/enum instead of def.values) - Update parseString to handle Zod 4's check format (uses item.format/item.def.check instead of item.kind) - Update tests to use t.like for flexibility with Zod 4's extra properties - Update error message assertions to handle Zod 4's different format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove @ts-nocheck and fix type errors properly - Replace ts-deepmerge with simple Object.assign (deep merge not needed for flat metadata) - Add ExtendedSchemaObject type for OpenAPI 3.0 nullable compatibility - Fix ZodObject generic parameters for Zod 3/4 compatibility - Fix discriminator null check - Use ZodTypeAny instead of ZodLiteral generic for compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
No longer needed since we use simple Object.assign for merging. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix getLiteralValue to use schema.value or def.values[0] for Zod 4 - Fix getChecks to normalize Zod 4 check objects by flattening _zod.def - Simplify parseString to use normalized check properties Zod 4 stores literal values in def.values (array) instead of def.value, and string checks have properties in check._zod.def instead of directly on the check object. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BREAKING CHANGE: This release upgrades the Zod peer dependency from v3 to v4. Users must upgrade their Zod dependency to ^4.0.0 to use this version. Zod 4 has internal API changes that required updates to the compatibility layer: - Schema definitions moved from ._def to ._zod.def - Literal values stored in def.values array instead of def.value - Check objects store properties in check._zod.def Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Jan 15, 2026
# [3.0.0](v2.20.0...v3.0.0) (2026-01-15) * feat!: upgrade to Zod 4 (#163) ([d829b41](d829b41)), closes [#163](#163) ### BREAKING CHANGES * This release upgrades the Zod peer dependency from v3 to v4. Users must upgrade their Zod dependency to ^4.0.0 to use this version. Zod 4 has internal API changes that required updates to the compatibility layer: - Schema definitions moved from ._def to ._zod.def - Literal values stored in def.values array instead of def.value - Check objects store properties in check._zod.def Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
^3.0.0 || ^4.0.0)Breaking Change
This is a major version bump. While the package supports both Zod 3 and Zod 4, users on Zod 3 should test thoroughly before upgrading.
Zod 4 Internal API Changes Handled
._defto._zod.def_def.typeNameto constructor names ($ZodString→ZodString)def.valuesarray instead ofdef.valuecheck._zod.definstead of directly on checkschema.optionsinstead ofdef.valuesTest Plan
type: "string", enum: ["value"]🤖 Generated with Claude Code