middleware
middleware copied to clipboard
Zod partial() function not available in the zod-openapi ?
partial() function not available in latest version 0.14.2?
https://zod.dev/?id=partial
Hi @vickyRathee
partial()function not available in latest version0.14.2?
Yes, it supports partial():
import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi'
const openapiHono = new OpenAPIHono().openapi(
createRoute({
method: 'get',
path: '/users/1',
responses: {
200: {
content: {
'application/json': {
schema: z
.object({
name: z.string().openapi({
example: 'John Doe'
}),
age: z.number().openapi({
example: 42
})
})
.partial()
.openapi('User')
}
},
description: 'Retrieve the user'
}
}
}),
(c) => {
return c.json({
age: 20,
name: 'Ultra-man'
})
}
)
Yes, thanks. It's working, but not with refine().partial()
I guess due to upstream.
@yusukebe Any suggestion, I can't use partial(), extend() etc when refine() is used.
@vickyRathee
I think refine().partial() is wrong. It should be partial().refine(). The latter will work well.