From 9ba022ebba031a31452485fd02547967b08248f6 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 25 Jul 2025 22:54:21 +0200 Subject: [PATCH 1/5] Zod plugin: Restore example and examples props on GlobalMeta. --- CHANGELOG.md | 4 ++++ express-zod-api/src/metadata.ts | 6 +++++- express-zod-api/src/zod-plugin.ts | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf46685ee..bbfe37023d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Version 24 +### v24.7.1 + + + ### v24.7.0 - Supporting `HEAD` method: diff --git a/express-zod-api/src/metadata.ts b/express-zod-api/src/metadata.ts index e1fb284721..c39aa91720 100644 --- a/express-zod-api/src/metadata.ts +++ b/express-zod-api/src/metadata.ts @@ -1,5 +1,6 @@ import { globalRegistry } from "zod/v4"; import type { $ZodType } from "zod/v4/core"; +import { isObject } from "./common-helpers"; export const metaSymbol = Symbol.for("express-zod-api"); @@ -23,7 +24,10 @@ export const getExamples = (subject: $ZodType): ReadonlyArray => { if (examples) { return Array.isArray(examples) ? examples - : Object.values(examples).map(({ value }) => value); + : /** @todo remove this branch in v25 */ + Object.values(examples) + .filter((one) => isObject(one) && "value" in one) + .map(({ value }) => value); } return example === undefined ? [] : [example]; }; diff --git a/express-zod-api/src/zod-plugin.ts b/express-zod-api/src/zod-plugin.ts index ecd615afb8..5e5050380e 100644 --- a/express-zod-api/src/zod-plugin.ts +++ b/express-zod-api/src/zod-plugin.ts @@ -40,6 +40,11 @@ declare module "ramda" { declare module "zod/v4/core" { interface GlobalMeta { default?: unknown; // can be an actual value or a label like "Today" + examples?: + | unknown[] // see zod commit ee5615d + | Record; // @todo remove in v25 + /** @deprecated use examples instead */ + example?: unknown; // see zod commit ee5615d @todo remove in v25 } } From 843bea709cbc2ca18b68b72d015b3c0b1e3725aa Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 25 Jul 2025 23:02:10 +0200 Subject: [PATCH 2/5] Changelog: 24.7.1. --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbfe37023d..cbfe37f1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,13 @@ ### v24.7.1 - +- Compatibility fix for `zod@^3.25.68` and `^4.0.0`: + - Previously typed metadata properties `example` and `examples` were removed from `zod` core: + See [Commit ee5615d](https://github.com/colinhacks/zod/commit/ee5615d76b93aac15d7428a17b834a062235f6a1); + - This version restores those properties as a part of Zod plugin in order to comply to the existing implementation; + - The `example` property is marked as deprecated and will be removed in v25 — please refrain from using it; + - The `examples` property still supports an object for backward compatibility, but it will only array in v25; + - To avoid confusion, consider using the Zod plugin's method `.example()` where possible (except `ez.dateIn()`). ### v24.7.0 From 450458273d25e208d1d8782cd3212e2eb0a4d7da Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 25 Jul 2025 23:06:11 +0200 Subject: [PATCH 3/5] more jsdoc and todo. --- express-zod-api/src/metadata.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/express-zod-api/src/metadata.ts b/express-zod-api/src/metadata.ts index c39aa91720..90a3ad8280 100644 --- a/express-zod-api/src/metadata.ts +++ b/express-zod-api/src/metadata.ts @@ -16,8 +16,10 @@ export const getBrand = (subject: $ZodType) => { }; /** - * @since zod 3.25.44 + * @since zod 3.25.44 can be an object * @link https://github.com/colinhacks/zod/pull/4586 + * @since zod 3.25.68 and 4.0.0 was completely removed + * @link https://github.com/colinhacks/zod/commit/ee5615d76b93aac15d7428a17b834a062235f6a1 * */ export const getExamples = (subject: $ZodType): ReadonlyArray => { const { examples, example } = globalRegistry.get(subject) || {}; @@ -29,5 +31,6 @@ export const getExamples = (subject: $ZodType): ReadonlyArray => { .filter((one) => isObject(one) && "value" in one) .map(({ value }) => value); } + /** @todo remove this in v25 */ return example === undefined ? [] : [example]; }; From 1dd05463c6e445a7e2a697482db21fac770a6da3 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 25 Jul 2025 23:07:57 +0200 Subject: [PATCH 4/5] rm filter. --- express-zod-api/src/metadata.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/express-zod-api/src/metadata.ts b/express-zod-api/src/metadata.ts index 90a3ad8280..c3504a2e96 100644 --- a/express-zod-api/src/metadata.ts +++ b/express-zod-api/src/metadata.ts @@ -1,6 +1,5 @@ import { globalRegistry } from "zod/v4"; import type { $ZodType } from "zod/v4/core"; -import { isObject } from "./common-helpers"; export const metaSymbol = Symbol.for("express-zod-api"); @@ -27,9 +26,7 @@ export const getExamples = (subject: $ZodType): ReadonlyArray => { return Array.isArray(examples) ? examples : /** @todo remove this branch in v25 */ - Object.values(examples) - .filter((one) => isObject(one) && "value" in one) - .map(({ value }) => value); + Object.values(examples).map(({ value }) => value); } /** @todo remove this in v25 */ return example === undefined ? [] : [example]; From 7e6f48090cfe87e6a0a9b3a9c099cd0824b5738e Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Fri, 25 Jul 2025 23:11:45 +0200 Subject: [PATCH 5/5] Changelog: typo. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfe37f1b4..7913ee3671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ See [Commit ee5615d](https://github.com/colinhacks/zod/commit/ee5615d76b93aac15d7428a17b834a062235f6a1); - This version restores those properties as a part of Zod plugin in order to comply to the existing implementation; - The `example` property is marked as deprecated and will be removed in v25 — please refrain from using it; - - The `examples` property still supports an object for backward compatibility, but it will only array in v25; + - The `examples` property still supports an object for backward compatibility, but it will only support array in v25; - To avoid confusion, consider using the Zod plugin's method `.example()` where possible (except `ez.dateIn()`). ### v24.7.0