Skip to content

Releases: RobinTail/express-zod-api

v24.2.3

05 Jun 19:14
Compare
Choose a tag to compare

Bug fix

Patch

Full Changelog: v24.2.2...v24.2.3

v24.2.2

04 Jun 07:57
Compare
Choose a tag to compare

Fix

  • Zod plugin compatibility fix #2702

Chores

Full Changelog: v24.2.1...v24.2.2

v24.2.1

03 Jun 05:59
Compare
Choose a tag to compare

What's Changed

Full Changelog: v24.2.0...v24.2.1

v24.2.0

02 Jun 20:41
Compare
Choose a tag to compare

Feature

Chores

Full Changelog: v24.1.0...v24.2.0

v24.1.0

01 Jun 10:24
Compare
Choose a tag to compare

Features

  • Support template literal schema by @RobinTail in #2659
  • Restored publicly exposed getExamples() helper in #2691

Fix

Chores

  • Upgrading all dependencies by @github-actions in #2688
  • Well-known headers update by @github-actions in #2689

Full Changelog: v24.0.0...v24.1.0

v24.0.0

31 May 09:14
b08e462
Compare
Choose a tag to compare

v24 is for Ashley

Version 24 introduces initial support for Zod 4, requiring at least version 3.25.35, but due to the special versioning strategy of Zod all imports must be changed to zod/v4. The framework simplifies the IOSchema type to explicitly require schemas that resolve to objects. Documentation generation now uses Zod 4’s native toJSONSchema() method, with custom overrides to align with OpenAPI 3.1, and the numericRange option has been removed. The Depicter type changed its signature, and brandHandling is now implemented as a postprocessing step. The optionalPropStyle option was removed from the Integration constructor. Using the Zod's internal storage for examples: method .example() changed its argument from z.input<> to z.output<> which is breaking for transforming schemas, so that examples of its input side must be set before the transformation. The getExamples() helper removed in favour of .meta()?.examples.

Breaking changes

  • Switched to Zod 4:
    • Minimum supported version of zod is 3.25.35, BUT imports MUST be from zod/v4;
      • Read the Explanation of the versioning strategy;
      • Express Zod API, however, is not aiming to support both Zod 3 and Zod 4 simultaneously due to:
        • incompatibility of data structures;
        • operating composite schemas (need to avoid mixing schemas of different versions);
        • the temporary nature of this transition;
        • the advantages of Zod 4 that provide opportunities to simplifications and corrections of known issues.
    • IOSchema type had to be simplified down to a schema resulting to an object, but not an array;
    • Refer to Migration guide on Zod 4 for adjusting your schemas;
  • Changes to ZodType::example() (Zod plugin method):
    • Now acts as an alias for ZodType::meta({ examples });
    • The argument has to be the output type of the schema (used to be the opposite):
      • This change is only breaking for transforming schemas;
      • In order to specify an example for an input schema the .example() method must be called before .transform();
  • The transforming proprietary schemas ez.dateIn() and ez.dateOut() now accept metadata as its argument:
    • This allows to set examples before transformation (ez.dateIn()) and to avoid the examples "branding";
  • Changes to Documentation:
    • Generating Documentation is mostly delegated to Zod 4 z.toJSONSchema();
    • Express Zod API implements some overrides and improvements to fit it into OpenAPI 3.1 that extends JSON Schema;
    • The numericRange option removed from Documentation class constructor argument;
    • The Depicter type signature changed: became a postprocessing function returning an overridden JSON Schema;
  • Changes to Integration:
    • The optionalPropStyle option removed from Integration class constructor:
    • Use .optional() to add question mark to the object property as well as undefined to its type;
    • Use .or(z.undefined()) to add undefined to the type of the object property;
    • See the reasoning;
    • Properties assigned with z.any() or z.unknown() schema are now typed as required:
    • Added types generation for z.never(), z.void() and z.unknown() schemas;
    • The fallback type for unsupported schemas and unclear transformations in response changed from any to unknown;
  • The argument of ResultHandler::handler is now discriminated: either output or error is null, not both;
  • The getExamples() public helper removed — use .meta()?.examples instead, restored in 24.1.0;
  • Added the new proprietary schema ez.buffer();
  • The ez.file() schema removed: use z.string(), z.base64(), ez.buffer() or their union;

Migration

Consider the automated migration using the built-in ESLint rule.

// eslint.config.mjs — minimal ESLint 9 config to apply migrations automatically using "eslint --fix"
import parser from "@typescript-eslint/parser";
import migration from "express-zod-api/migration";

export default [
  { languageOptions: { parser }, plugins: { migration } },
  { files: ["**/*.ts"], rules: { "migration/v24": "error" } },
];
- import { z } from "zod";
+ import { z } from "zod/v4";
  input: z.string()
+   .example("123")
    .transform(Number)
-   .example("123")
- ez.dateIn().example("2021-12-31");
+ ez.dateIn({ examples: ["2021-12-31"] });
- ez.file("base64");
+ z.base64();
- ez.file("buffer");
+ ez.buffer();

v23.6.1

26 May 21:11
Compare
Choose a tag to compare

Patch

Chores

Full Changelog: v23.6.0...v23.6.1

v23.6.0

23 May 07:19
Compare
Choose a tag to compare

Feature

Chores

Full Changelog: v23.5.0...v23.6.0

v23.5.0

20 May 03:26
Compare
Choose a tag to compare

Feature

Chores

Full Changelog: v23.4.1...v23.5.0

v23.4.1

17 May 08:15
Compare
Choose a tag to compare

Fix

Chores

Full Changelog: v23.4.0...v23.4.1