express-zod-openapi
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -70,1 +70,8 @@ ### 0.0.1 (2022-03-04) | ||
## [0.0.11](https://github.com/MunifTanjim/express-zod-openapi/compare/0.0.10...0.0.11) (2023-10-16) | ||
### Bug Fixes | ||
* validate response before stringification ([20fb1e8](https://github.com/MunifTanjim/express-zod-openapi/commit/20fb1e8a3f158f1ce8cb47a5fcc33283548d8600)) | ||
@@ -436,10 +436,8 @@ var zodToJsonSchema = require('zod-to-json-schema'); | ||
function setupResponseValidation(res, spec, segmentOrder, next) { | ||
const originalSend = res.send; | ||
const originalJson = res.json; | ||
res.send = function validateAndSendResponse(...args) { | ||
res.send = originalSend; | ||
const body = args[0]; | ||
const isJsonContent = /application\/json/.test(String(res.get('content-type'))); | ||
res.json = function validateAndSendJsonResponse(...args) { | ||
res.json = originalJson; | ||
const value = { | ||
body: isJsonContent ? JSON.parse(body) : body, | ||
body: args[0], | ||
headers: res.getHeaders() | ||
@@ -473,3 +471,3 @@ }; | ||
return originalSend.apply(res, [isJsonContent ? JSON.stringify(value.body) : value.body]); | ||
return res.json(value.body); | ||
}; | ||
@@ -476,0 +474,0 @@ } |
@@ -436,10 +436,8 @@ import { zodToJsonSchema } from 'zod-to-json-schema'; | ||
function setupResponseValidation(res, spec, segmentOrder, next) { | ||
const originalSend = res.send; | ||
const originalJson = res.json; | ||
res.send = function validateAndSendResponse(...args) { | ||
res.send = originalSend; | ||
const body = args[0]; | ||
const isJsonContent = /application\/json/.test(String(res.get('content-type'))); | ||
res.json = function validateAndSendJsonResponse(...args) { | ||
res.json = originalJson; | ||
const value = { | ||
body: isJsonContent ? JSON.parse(body) : body, | ||
body: args[0], | ||
headers: res.getHeaders() | ||
@@ -473,3 +471,3 @@ }; | ||
return originalSend.apply(res, [isJsonContent ? JSON.stringify(value.body) : value.body]); | ||
return res.json(value.body); | ||
}; | ||
@@ -476,0 +474,0 @@ } |
{ | ||
"name": "express-zod-openapi", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Express Zod OpenAPI", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
569342
1421