这是indexloc提供的服务,不要输入任何密码
Skip to content

.meta() is ignored in toJSONSchema unless its the last chained method (using Zod v4) #5447

@IdoBouskila

Description

@IdoBouskila

Hi, when generating JSON Schema with z.toJSONSchema, metadata added with .meta() is only included if .meta() is the final method in the chain.

Example where metadata is lost:

const schema = z.object({
  name: z.string().meta({ describe: 'first name' }).min(1)
});

Example where metadata works:

```ts
const schema = z.object({
  name: z.string().min(1).meta({ describe: 'A user name' })
});

Is it expected? feels unintuitive that order matters here

Thanks for taking a look! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions