Skip to content

Conversation

@yokotaso
Copy link

Summary

This PR updates all example code to use zod/v4 imports instead of the default zod import, preparing for Zod v4 compatibility.

Changes

  • Updated all import z from "zod" to import z from "zod/v4" in example files
  • Changed .openapi() to .meta() method for OpenAPI metadata (aligning with Zod v4 API changes)
  • Updated examples in:
    • 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

🤖 Generated with Claude Code

@yokotaso yokotaso requested a review from Copilot December 24, 2025 07:01
Copy link

Copilot AI left a 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" to import 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, and zod-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";
Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
import z from "zod/v4";
import z from "zod/v4";
import "zod-openapi/extend";

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@shinagawa-web shinagawa-web left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yokotaso
LGTMです!

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.

3 participants