Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"peerDependencies": {
"@trpc/server": "^11.1.0",
"zod": "^4.0.0",
"zod": "^3.25.0 || ^4.0.0",
"zod-openapi": "^5.0.1"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/node-http/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
type NodeHTTPResponse,
} from '@trpc/server/adapters/node-http';
import { getErrorShape, TRPCRequestInfo } from '@trpc/server/unstable-core-do-not-import';
import { ZodArray, ZodError, ZodTypeAny } from 'zod';
import { ZodArray } from 'zod/v4';
import type { ZodError } from 'zod/v4';
import { NodeHTTPRequest } from '../../types';
Comment thread
mcampa marked this conversation as resolved.
import { generateOpenApiDocument } from '../../generator';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/generator/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZodOpenApiObject, ZodOpenApiPathsObject, createDocument } from 'zod-openapi';
import { ZodSchema } from 'zod';
import type { ZodSchema } from 'zod/v4';

Comment thread
mcampa marked this conversation as resolved.
import {
OpenApiMeta,
Expand Down
3 changes: 2 additions & 1 deletion src/generator/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TRPCError } from '@trpc/server';
import { ZodObject, ZodAny, z } from 'zod';
import { z } from 'zod/v4';
import type { ZodObject, ZodAny } from 'zod/v4';
import {
Comment thread
mcampa marked this conversation as resolved.
ZodOpenApiContentObject,
ZodOpenApiParameters,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
RouterRecord,
} from '@trpc/server/unstable-core-do-not-import';
import { IncomingMessage } from 'http';
import type { ZodObject } from 'zod';
import type { ZodObject } from 'zod/v4';
import type { $ZodIssue } from 'zod/v4/core';

export { type OpenAPIObject, type SecuritySchemeObject } from 'openapi3-ts/oas31';
Expand Down
3 changes: 2 additions & 1 deletion src/utils/procedure.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TRPCProcedureType } from '@trpc/server';
import { ZodObject, z } from 'zod';
import { z } from 'zod/v4';
import type { ZodObject } from 'zod/v4';

Comment thread
mcampa marked this conversation as resolved.
import { OpenApiMeta, OpenApiProcedure, OpenApiProcedureRecord } from '../types';

Expand Down
3 changes: 2 additions & 1 deletion src/utils/zod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ZodObject, ZodRawShape, ZodType, z } from 'zod';
import { z } from 'zod/v4';
import type { ZodObject, ZodRawShape, ZodType } from 'zod/v4';
import type { $ZodType, $ZodTypes } from 'zod/v4/core';
import type { $ZodTypeDef } from 'zod/v4/core/schemas';

Expand Down
2 changes: 1 addition & 1 deletion test/adapters/express.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { initTRPC } from '@trpc/server';
import express from 'express';
import fetch from 'node-fetch';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiExpressMiddlewareOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/fastify.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { initTRPC } from '@trpc/server';
import fastify from 'fastify';
import fetch from 'node-fetch';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiFastifyPluginOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TRPCError, initTRPC } from '@trpc/server';
import fetch from 'node-fetch';
import superjson from 'superjson';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiFetchHandlerOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/koa.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { initTRPC } from '@trpc/server';
import Koa from 'koa';
import fetch from 'node-fetch';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiKoaMiddlewareOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
import { IncomingHttpHeaders, IncomingMessage } from 'http';
import { NextApiRequestCookies, NextApiRequestQuery } from 'next/dist/server/api-utils';
import { Socket } from 'net';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiNextHandlerOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/nuxt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { initTRPC } from '@trpc/server';
import { H3Event } from 'h3';
import httpMocks, { RequestMethod } from 'node-mocks-http';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiNuxtHandlerOptions,
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/standalone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createHTTPHandler } from '@trpc/server/adapters/standalone';
import { Server } from 'http';
import fetch from 'node-fetch';
import superjson from 'superjson';
import { z } from 'zod';
import { z } from 'zod/v4';

import {
CreateOpenApiHttpHandlerOptions,
Expand Down
9 changes: 7 additions & 2 deletions test/generator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { initTRPC } from '@trpc/server';
import { observable } from '@trpc/server/observable';
import { z } from 'zod';
import { z } from 'zod/v4';

import { GenerateOpenApiDocumentOptions, OpenApiMeta, generateOpenApiDocument } from '../src';
import * as zodUtils from '../src/utils/zod';
Expand Down Expand Up @@ -3165,7 +3165,12 @@ describe('generator', () => {
.input(
z
.object({ name: z.string() })
.meta({ examples: { Lily: { name: 'Lily' }, John: { name: 'John' } } }),
// zod-openapi v5 types `meta.examples` as `unknown[]`, but its runtime
// still accepts the v3-style named-record form used here (and emits it
// through to the output schema verbatim — see snapshot below).
.meta({
examples: { Lily: { name: 'Lily' }, John: { name: 'John' } } as unknown as unknown[],
}),
Comment thread
mcampa marked this conversation as resolved.
)
.output(z.object({ output: z.string() }))
.mutation(({ input }) => ({
Expand Down
Loading