Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining partial with null in a union type results in double producing null type matcher #233

Open
brent-statsig opened this issue May 22, 2024 · 1 comment

Comments

@brent-statsig
Copy link

The code below is causing problems for my use case, and I can't successfully generate a valid openapi definition because of it. Let me know if you need any more context!

Offending ZOD repro

export const ConditionSchema = z
  .object({
    targetValue: z.union([
      z.string().array(),
      z.number().array(),
      z.string(),
      z.number(),
      z.null(),
    ]),
  })
  .partial({ targetValue: true });

Generated openapi block

"anyOf": [
  { "type": "array", "items": { "type": "string" } },
  { "type": "array", "items": { "type": "number" } },
  { "type": "string" },
  { "type": "number" },
  { "type": "null" },
  { "type": "null" }
]
@AGalabov
Copy link
Collaborator

@brent-statsig thank you for reporting that. Right now it is kind of hard to find time for such fixes, but I'll try and get to take a look at it whenever I can. In the meantime if you have an idea on how to fix it - feel free to open up a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants