-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add options for datetime into zod plugin #1881
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! You'll want to pass plugin
around instead of creating your own config variable. It should contain all you need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to run the tests to check if CI passes, but we'll also need snapshot tests covering this functionality
@@ -463,6 +471,11 @@ const stringTypeToZodSchema = ({ | |||
expression: stringExpression, | |||
name: compiler.identifier({ text: 'datetime' }), | |||
}), | |||
parameters: [ | |||
plugin.dateTimeOptions | |||
? JSON.stringify(plugin.dateTimeOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually surprised this works 😂 it wouldn't work if you passed the object instead of string? I'd feel more comfortable with doing that, although being even more explicit and constructing the object would be ideal. Right now I'd need to go back to config to check what it contains. I worry it will break if the config shape changes. I don't want to introduce this as a pattern for other plugins, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried other things but the only thing is working is to pass a stringfiied object to have the correct output.
There is another way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see that parameter object being constructed in the plugin, even if it's assigning the same config values to an object. Have a look at how we do parameters elsewhere we call this function. It will eliminate the need to cross reference another file
Also are there any other options like this we could introduce later? As in for booleans or other types? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1881 +/- ##
==========================================
- Coverage 57.23% 57.17% -0.07%
==========================================
Files 191 191
Lines 25954 25984 +30
Branches 1964 1964
==========================================
Hits 14856 14856
- Misses 11089 11119 +30
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/client-axios
@hey-api/client-fetch
@hey-api/client-next
@hey-api/client-nuxt
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/vite-plugin
commit: |
Actually, we only have something like this
Tha goal is providing datetime options given by zod documentation
https://zod.dev/?id=datetimes
With this kind of plugin declaration inside openapi-ts.config.ts
we can have something like this
I'm not confortables about hey-api plugins so, feel free to make corrections.