Skip to content

Commit e46e167

Browse files
authored
Fix negative response MIME type for arrayResultHandler (#2857)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected the negative response MIME type for deprecated error handling to use "text/plain" instead of "application/json" in both documentation and response handling. * **Documentation** * Updated the changelog to reflect the fix for the negative response MIME type. * Adjusted API documentation to specify "text/plain" as the content type for certain error responses. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 77e378e commit e46e167

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Version 24
44

5+
### v24.7.2
6+
7+
- Fixed the negative response MIME type for ~~`arrayResultHandler`~~ (deprecated entity):
8+
- Should have been `text/plain`.
9+
510
### v24.7.1
611

712
- Compatibility fix for `zod@^3.25.68` and `^4.0.0`:

example/example.documentation.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ paths:
441441
"400":
442442
description: GET /v1/user/list Negative response
443443
content:
444-
application/json:
444+
text/plain:
445445
schema:
446446
type: string
447447
examples:
@@ -457,7 +457,7 @@ paths:
457457
"400":
458458
description: HEAD /v1/user/list Negative response
459459
content:
460-
application/json:
460+
text/plain:
461461
schema:
462462
type: string
463463
examples:

express-zod-api/src/result-handler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ export const arrayResultHandler = new ResultHandler({
169169
}
170170
return responseSchema;
171171
},
172-
negative: z.string().example("Sample error message"),
172+
negative: {
173+
schema: z.string().example("Sample error message"),
174+
mimeType: "text/plain",
175+
},
173176
handler: ({ response, output, error, logger, request, input }) => {
174177
if (error) {
175178
const httpError = ensureHttpError(error);

0 commit comments

Comments
 (0)