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

Parameter types incorrect when using default values #64

Closed
epotter2297 opened this issue Oct 29, 2022 · 2 comments
Closed

Parameter types incorrect when using default values #64

epotter2297 opened this issue Oct 29, 2022 · 2 comments

Comments

@epotter2297
Copy link

If I have an API definition with a parameter like this:

{
  name: 'limit',
  type: 'Query',
  schema: z.number().positive().default(10),
},

In my router, req.query.limit is of type number | undefined. I would expect it to be number due to the default value.

@ecyrbe
Copy link
Owner

ecyrbe commented Oct 29, 2022

Oh yes, this one is tricky. Thanks for the report.

In frontend, the type is correct, because it allows effectively you to not pass any value.

But in the backend, you effectively expect the value to be generated, so yes indeed, you expect it to be number.

I'll need to extend @zodios/core to add support for this.

@ecyrbe
Copy link
Owner

ecyrbe commented Oct 29, 2022

@epotter2297 This is now fixed in version @zodios/core v10.4.4 and @zodios/express v10.4.3

@ecyrbe ecyrbe closed this as completed Oct 29, 2022
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