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

[zod-openapi] cannot handle nested types #227

Open
matthew-kaye opened this issue Oct 3, 2024 · 0 comments
Open

[zod-openapi] cannot handle nested types #227

matthew-kaye opened this issue Oct 3, 2024 · 0 comments

Comments

@matthew-kaye
Copy link

matthew-kaye commented Oct 3, 2024

const zAddress = z
  .object({
    line1: z.string(),
    line2: z.string(),
    city: z.string(),
    province: z.string(),
    country: z.string(),
    postalCode: z.string(),
  })

const response = extendApi(
  z.object({
    data: z.object({
      ...
      address: zAddress,
    }),
  }),
);

When I try to build swagger docs based off of this I get the following error:

Found undefined and using theme.openapi options
Prerendering docs
TypeError: t.required.indexOf is not a function

It works if I make the address an empty object, but for some reason when I define the keys of the address object the required field gets messed up and becomes a boolean when it should be an array of the required fields. I've attempted multiple workarounds with no luck

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

1 participant