Skip to content
Discussion options

You must be logged in to vote

I can't reproduce this on zod 4.4.3 — usage-site descriptions survive in every arrangement I tried, including the ones suggested above as the cause. Rather than guess at what's different, here's the harness so you can point at the case that breaks.

import { z } from 'zod'

const mkUnion = () => z.union([
  z.object({ kind: z.literal('bar'), n: z.number() }),
  z.object({ kind: z.literal('zed'), s: z.string() }),
])

const u = mkUnion()
const coolObj = z.object({
  aThing: u.meta({ description: 'for a' }),
  bThing: u.meta({ description: 'for b' }),
})

console.log(JSON.stringify(z.toJSONSchema(coolObj), null, 2))

Results across the variations, checking whether aThing / bThing keep their own

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@FoxxMD
Comment options

@dosubot
Comment options

Comment options

You must be logged in to vote
1 reply
@FoxxMD
Comment options

Answer selected by FoxxMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants