Marcel Overdijk
Marcel Overdijk
Explore posts from servers
HHono
Created by Marcel Overdijk on 4/15/2024 in #help
Validate response objects
Using the zod validator middleware it is possible to validate params , query, request body like:
const route = app.post(
'/posts',
zValidator(
'form',
z.object({
body: z.string(),
})
),
(c) => {
// ...
return {
..
}
}
)
const route = app.post(
'/posts',
zValidator(
'form',
z.object({
body: z.string(),
})
),
(c) => {
// ...
return {
..
}
}
)
But is it also possible to validate the response object returned by the handler, to eg make sure response does contain required properties, but also does not include any unwanted properties?
4 replies
HHono
Created by Marcel Overdijk on 4/9/2024 in #help
How to generate openapi.yaml spec with Zod OpenAPI Hono?
Is it possible to generate the openapi.yaml spec with Zod OpenAPI Hono from the commandline using a npm command? I need this in my development workflow to use the openapi.yaml to generate some other client code from the spec.
4 replies