-
Notifications
You must be signed in to change notification settings - Fork 204
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
Response with null
body yields a compile error, which should be allowed for 204
#205
Comments
null
body yields a compile errornull
body yields a compile error, which should be allowed for 204
One of the problems is that if you pass
If you wish to return a 204 status code, you can use One idea to address this issue is to make the expected type app.openapi(
createRoute({
method: 'get',
path: '/',
responses: {
204: {
description: 'No Content',
},
},
}),
(c) => {
return c.body(null, 204)
}
) To enable this, allow the response type to be |
This PR #206 might resolve this issue. What do you think it? |
I agree with that solution. In my current use case, just checking |
This is a continuation from honojs/hono#1529 (comment), which I still think is a problem on second thought.
This is the reproduction code I've shown in the issue above
and
c.jsonT(null)
yields the following compile error.Replacing
null
with{}
eliminates the compile error but is problematic in case of 204 status response. You have to usenull
as a response body if the status is 204:Returning either
null
or{}
for 4xx/5xx responses might be a personal preference (I'd prefer the former), but I'd be happy if we can returnnull
in Zod OpenAPI Hono because there are no choices for 204.The text was updated successfully, but these errors were encountered: