-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix(zod-openapi): return Response
if response is not text or JSON
#853
Conversation
Co-authored-by: sushichan044 <mail@sushichan.live>
🦋 Changeset detectedLatest commit: 3096667 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -1779,21 +1779,21 @@ describe('RouteConfigToTypedResponse', () => { | |||
age: number | |||
}, | |||
200, | |||
'json' | 'text' | |||
'json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since now the TypedResponse
only allows json
with application/json
, I fixed the test.
? ContentType extends `application/${infer Start}json${infer _End}` | ||
? Start extends '' | `${string}+` | `vnd.${string}+` | ||
? TypedResponse< | ||
SimplifyDeepArray<Content> extends JSONValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is following JSONRespondReturn
, which is introduced in hono
.
Hi @sushichan044! What do you think of this PR? |
@yusukebe Looks good! |
Thanks! I'll merge this. But I like your implementation! |
Fixes #842
#852 was a great PR to fix #842. However, type errors should not arise for responses other than HTML. Example:
application/xml
. So, the problem will be solved if we setResponse
to contents other than JSON or Text like the following.TypedRespose
withjson
TypedResponse
withtext
Response
This PR will correct whether the returned value should be a
TypedResponse
or aResponse
based on the specified content type.