Fixed issue where for some of request body with JSON family headers were not correctly generated

This commit is contained in:
Vishal Shingala
2022-09-29 13:46:17 +05:30
parent 4786d4dc1c
commit 35dcf311f0
2 changed files with 76 additions and 10 deletions

View File

@@ -2015,26 +2015,28 @@ module.exports = {
}
else {
let getXmlVersionContent = (bodyContent) => {
const regExp = new RegExp('([<\\?xml]+[\\s{1,}]+[version="\\d.\\d"]+[\\sencoding="]+.{1,15}"\\?>)');
let xmlBody = bodyContent;
const regExp = new RegExp('([<\\?xml]+[\\s{1,}]+[version="\\d.\\d"]+[\\sencoding="]+.{1,15}"\\?>)');
let xmlBody = bodyContent;
if (!bodyContent.match(regExp)) {
const versionContent = '<?xml version="1.0" encoding="UTF-8"?>\n';
xmlBody = versionContent + xmlBody;
}
return xmlBody;
};
if (!bodyContent.match(regExp)) {
const versionContent = '<?xml version="1.0" encoding="UTF-8"?>\n';
xmlBody = versionContent + xmlBody;
}
return xmlBody;
},
headerFamily;
bodyData = this.convertToPmBodyData(contentObj[bodyType], requestType, bodyType,
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
bodyData = (bodyType === TEXT_XML || bodyType === APP_XML) ?
headerFamily = this.getHeaderFamily(bodyType);
bodyData = (bodyType === TEXT_XML || bodyType === APP_XML || headerFamily === HEADER_TYPE.XML) ?
getXmlVersionContent(bodyData) :
bodyData;
updateOptions = {
mode: rDataMode,
raw: bodyType !== APP_JSON ?
raw: !_.isObject(bodyData) && _.isFunction(_.get(bodyData, 'toString')) ?
bodyData.toString() :
JSON.stringify(bodyData, null, options.indentCharacter)
};