You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, suppose I want to specify a numeric id as a path parameter.
If I do z.number() with @hono/zod-openapi, the OpenAPI schema will be numeric as expected, but the actual path parameter will be passed a string id, so I get a validation error.
Next, if I do z.string(), it does not result in a validation error, but the OpenAPI schema also results in the id being a string. Also, it is possible to specify a non-numeric value.
Furthermore, if I set z.coerce.number(), the OpenAPI schema will be numeric and there will be no validation error, but "required": false will be set even though it is required.
Finally I tried defining it as follows, is there a smarter way?
Also, is there a better way to inherit the schema from createSelectSchema in drizzle-zod?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For example, suppose I want to specify a numeric id as a path parameter.
If I do
z.number()
with@hono/zod-openapi
, the OpenAPI schema will be numeric as expected, but the actual path parameter will be passed a string id, so I get a validation error.Next, if I do
z.string()
, it does not result in a validation error, but the OpenAPI schema also results in the id being a string. Also, it is possible to specify a non-numeric value.Furthermore, if I set
z.coerce.number()
, the OpenAPI schema will be numeric and there will be no validation error, but"required": false
will be set even though it is required.Finally I tried defining it as follows, is there a smarter way?
Also, is there a better way to inherit the schema from
createSelectSchema
indrizzle-zod
?ref mikan3rd/hono-next-example#47
Beta Was this translation helpful? Give feedback.
All reactions