From 3420f020495f738adc6474a4fc2ce7116372ae53 Mon Sep 17 00:00:00 2001 From: Tim <> Date: Mon, 6 Sep 2021 14:49:14 +0200 Subject: [PATCH] Skip automatic header addition when "keepImplicitHeaders" is active, to prevent duplicate headers. --- lib/schemaUtils.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/schemaUtils.js b/lib/schemaUtils.js index 1bc69a8..b3113ac 100644 --- a/lib/schemaUtils.js +++ b/lib/schemaUtils.js @@ -1878,12 +1878,10 @@ module.exports = { raw: JSON.stringify(bodyData, null, 4) }; - if (!options.keepImplicitHeaders) { - contentHeader = new sdk.Header({ - key: 'Content-Type', - value: bodyType - }); - } + contentHeader = new sdk.Header({ + key: 'Content-Type', + value: bodyType + }); reqBody.update(updateOptions); } @@ -2358,7 +2356,9 @@ module.exports = { } pmBody = this.convertToPmBody(reqBody, REQUEST_TYPE.ROOT, components, options, schemaCache); item.request.body = pmBody.body; - item.request.addHeader(pmBody.contentHeader); + if (!options.keepImplicitHeaders || (reqParams.header && reqParams.header.length === 0)) { + item.request.addHeader(pmBody.contentHeader); + } // extra form headers if encoding is present in request Body. // TODO: Show warning for incorrect schema if !pmBody.formHeaders pmBody.formHeaders && pmBody.formHeaders.forEach((element) => {