Skip to content

v25: example is not a function #2981

@squishykid

Description

@squishykid

Description

Upgrading from v24 to v25 appears to break examples in generated documentation. I created a git repo which reproduces this issue: https://github.com/squishykid/express-zod-api-example-issue

There are two ways this library allows developers to provide examples:

  • .example()
  • .meta()

Upon upgrading from 24.7.3 to 25.0.0 it appears that both of these methods of providing examples break in different ways.

Examples supplied via the .meta() method simply vanish silently from the generated documentation. Perhaps zod's globalRegistry is not as global any more? I notice that examples (default error messages) added by this library continue to be included in the documentation yaml output.

Examples supplied via the .example() method cause a compile error after upgrading from v24.7.3 to v25.0.0:

}).example({ name: 'bingo' });
   ^

TypeError: zod_1.z.object(...).example is not a function

Expected

I would have expeted .example() and .meta() to both produce examples in the documentation output, regardless of using v24.x or v25.x of this library.

Reproduction

I have created a repository here which extends a previous minimal example for zod bugs.

The repo currently uses v24.7.3, but upon upgrading to v25.0.0 the bug will be triggered.

https://github.com/squishykid/express-zod-api-example-issue

Context

  • Node.js version: 22.20.0
  • express-zod-api version: v24.7.3 to v25.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingBackward incompatible changesgood first issueGood for newcomershacktoberfest-acceptedThe PR is a valuable contribution according to Hacktoberfest guidelines

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions