-
Notifications
You must be signed in to change notification settings - Fork 2
chore: Update examples to use zod/v4 imports #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates all example and test code to use the zod/v4 import path instead of the default zod import, and updates package dependencies to support Zod v4. The changes also include updating test assertions to match Zod v4's new error message formats and changing .openapi() method calls to .meta() to align with Zod v4 API changes.
- Updated all
import z from "zod"toimport z from "zod/v4"across examples and tests - Changed
.openapi()method to.meta()for OpenAPI metadata - Updated error message assertions in tests to match Zod v4's error format
- Upgraded dependencies including
zod,fastify-type-provider-zod, andzod-openapi
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkgs/typed-api-spec/src/msw/http.test.ts | Updated zod import path in MSW test file |
| pkgs/typed-api-spec/src/fetch/validation.no-test.ts | Updated commented-out zod import in validation test |
| pkgs/typed-api-spec/src/fetch/index.t-test.ts | Updated zod import path in fetch type test |
| pkgs/typed-api-spec/src/express/zod.test.ts | Updated zod import and error message assertions for v4 compatibility |
| pkgs/typed-api-spec/src/core/schema.t-test.ts | Updated zod import path in core schema type test |
| pkgs/typed-api-spec/src/core/openapi/openapi-zod.test.ts | Updated zod import, removed zod-openapi extend, added additionalProperties flags |
| pkgs/typed-api-spec/package.json | Upgraded zod, fastify-type-provider-zod, and zod-openapi dependencies |
| pkgs/docs/docs/06_validation/zod.md | Updated zod import in documentation examples |
| pkgs/docs/docs/06_validation/concept.md | Updated zod import in validation concept documentation |
| pkgs/docs/docs/05_server/msw.md | Updated zod import in MSW server documentation |
| pkgs/docs/docs/05_server/express.md | Updated zod import in Express server documentation |
| pkgs/docs/docs/03_api-specification.md | Updated zod import in API specification documentation |
| examples/vite/src/github/spec.ts | Updated zod import in Vite example |
| examples/misc/spec/zod.ts | Updated zod import in spec example |
| examples/misc/simple/withValidation.ts | Updated zod import in validation example |
| examples/misc/fastify/zod/fastify.ts | Updated ZodError import in Fastify example |
| examples/misc/express/zod/openapi/index.ts | Updated zod import and changed .openapi() to .meta() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { OpenAPIV3_1 } from "openapi-types"; | ||
| import "zod-openapi/extend"; | ||
| import z from "zod"; | ||
| import z from "zod/v4"; |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of import \"zod-openapi/extend\" may break OpenAPI metadata generation functionality. If zod-openapi v5 still requires this import for extending zod with OpenAPI capabilities, it should be retained.
| import z from "zod/v4"; | |
| import z from "zod/v4"; | |
| import "zod-openapi/extend"; |
shinagawa-web
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yokotaso
LGTMです!
Summary
This PR updates all example code to use
zod/v4imports instead of the defaultzodimport, preparing for Zod v4 compatibility.Changes
import z from "zod"toimport z from "zod/v4"in example files.openapi()to.meta()method for OpenAPI metadata (aligning with Zod v4 API changes)examples/misc/express/zod/openapi/examples/misc/fastify/zod/examples/misc/simple/examples/misc/spec/examples/vite/src/github/Context
Zod v4 introduces a new import path (
zod/v4) that allows gradual migration. This PR updates the examples to demonstrate best practices for using typed-api-spec with Zod v4, while maintaining backward compatibility through peer dependencies.Breaking Changes
None - this only affects example code and does not change the library's API.
Related
zod ^3.25.74which includes the v4 import path🤖 Generated with Claude Code