mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Adding xml version data to body if not present
- When content is text/xml and the provided body or example does not contain the version data it will be added at the beginning.
This commit is contained in:
@@ -1932,7 +1932,18 @@ module.exports = {
|
||||
else {
|
||||
bodyData = this.convertToPmBodyData(contentObj[bodyType], requestType, bodyType,
|
||||
PARAMETER_SOURCE.REQUEST, options.indentCharacter, components, options, schemaCache);
|
||||
|
||||
let getXmlVersionContent = (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"?>';
|
||||
xmlBody = versionContent + xmlBody;
|
||||
}
|
||||
return xmlBody;
|
||||
};
|
||||
bodyData = bodyType === TEXT_XML ?
|
||||
getXmlVersionContent(bodyData) :
|
||||
bodyData;
|
||||
updateOptions = {
|
||||
mode: rDataMode,
|
||||
raw: bodyType !== APP_JSON ?
|
||||
|
||||
Reference in New Issue
Block a user