From 235c4db03962669149fa5be01bb7c0a30e9569bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neves?= Date: Mon, 11 Nov 2019 17:11:44 +0000 Subject: [PATCH] Fix req.path uniqueness in response validators caching. --- src/middlewares/openapi.response.validator.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middlewares/openapi.response.validator.ts b/src/middlewares/openapi.response.validator.ts index 7ad6cc63..fa9cd43b 100644 --- a/src/middlewares/openapi.response.validator.ts +++ b/src/middlewares/openapi.response.validator.ts @@ -31,7 +31,7 @@ export class ResponseValidator { const responses = req.openapi.schema && req.openapi.schema.responses; const validators = this._getOrBuildValidator(req, responses); const statusCode = res.statusCode; - const path = req.path; + const path = req.originalUrl; return this._validate({ validators, body, statusCode, path }); } return body; @@ -46,7 +46,7 @@ export class ResponseValidator { } const contentType = extractContentType(req) || 'not_provided'; - const key = `${req.method}-${req.path}-${contentType}`; + const key = `${req.method}-${req.originalUrl}-${contentType}`; let validators = this.validatorsCache[key]; if (!validators) {