mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Fixed issue where for some of request body with JSON family headers were not correctly generated
This commit is contained in:
@@ -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)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user