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(plugins/zod): fix support for string types in binary format #1616

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nedpals
Copy link

@nedpals nedpals commented Jan 23, 2025

This fixes support for string types in binary formats by converting the stringExpression into a Zod union type with File and Blob. It matches the behavior of @hey-api/typescript's handling of the said type.

Copy link

stackblitz bot commented Jan 23, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Jan 23, 2025

🦋 Changeset detected

Latest commit: f841028

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 24, 2025 2:35pm

@nedpals nedpals changed the title feat(plugins/zod): add support for string types in binary format fix(plugins/zod): fix support for string types in binary format Jan 23, 2025
@mrlubos
Copy link
Member

mrlubos commented Jan 23, 2025

Hi @nedpals, are you able to add tests please?

@nedpals
Copy link
Author

nedpals commented Jan 23, 2025

@mrlubos overlooked it my bad. will add the tests once i get back online tomorrow

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 4.76190% with 20 lines in your changes missing coverage. Please review.

Project coverage is 56.22%. Comparing base (3d17490) to head (f841028).

Files with missing lines Patch % Lines
packages/openapi-ts/src/plugins/zod/plugin.ts 4.76% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1616      +/-   ##
==========================================
- Coverage   56.26%   56.22%   -0.05%     
==========================================
  Files         158      158              
  Lines       24875    24896      +21     
  Branches     1816     1816              
==========================================
+ Hits        13997    13998       +1     
- Misses      10868    10888      +20     
  Partials       10       10              
Flag Coverage Δ
unittests 56.22% <4.76%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

pkg-pr-new bot commented Jan 24, 2025

Open in Stackblitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@1616

commit: f841028

@mrlubos
Copy link
Member

mrlubos commented Jan 25, 2025

@nedpals Actually I do have a question here. Since it's now no longer matching strings, won't this fail response validations?

@nedpals
Copy link
Author

nedpals commented Jan 26, 2025

@nedpals Actually I do have a question here. Since it's now no longer matching strings, won't this fail response validations?

My use case for this is for form validation (react-hook-forms specifically) since I presume that the correct response types were already inferred during client generation.

Another thing is that I also expect that it should match 1:1 with the generated Typescript types.

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.

2 participants