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

fix: zod additional properties error #972

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

CxGarcia
Copy link

@CxGarcia CxGarcia commented Oct 19, 2023

Status

READY

Description

in zod generator, the additionalProperties that are appended to functions array are either an array or a boolean (see code). however, parseProperty function is treating them all as arrays and using array methods which causes a runtime error. you can reproduce the error by running zod generator on this file

this PR fixes the error and uses the passthrough method when additionalProperties are set to true to avoid unknown keys being stripped from the object by zod

Todos

  • Tests
  • Documentation (N/A)
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

git pull https://github.com/CxGarcia/orval
cd orval
git checkout fix/zod-additional-properties
yarn build
(cd tests && yarn generate:zod)

@vercel
Copy link

vercel bot commented Oct 19, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @anymaniax on Vercel.

@anymaniax first needs to authorize it.

@CxGarcia CxGarcia marked this pull request as ready for review October 19, 2023 13:06
@CxGarcia CxGarcia changed the title fix: zod additional properties fix: zod additional properties error Oct 19, 2023
melloware
melloware previously approved these changes Oct 19, 2023
@melloware melloware force-pushed the fix/zod-additional-properties branch from 2300d2c to e3a01cd Compare October 26, 2023 11:57
@melloware
Copy link
Collaborator

Looks like tests are failing?

@melloware melloware self-requested a review October 26, 2023 13:10
Copy link
Collaborator

@melloware melloware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are still failing...

@melloware
Copy link
Collaborator

Errors...

Error: generated/zod/additionalProperties.ts(18,16): error TS2554: Expected 1-3 arguments, but got 0.
Error: generated/zod/additionalProperties.ts(18,25): error TS2339: Property 'passthrough' does not exist on type 'ZodRecord<ZodString, ZodTypeAny>'.

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

Successfully merging this pull request may close these issues.

None yet

2 participants