mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Take format from root
take the format of each root when the option for the process is not present
This commit is contained in:
@@ -4839,8 +4839,32 @@ module.exports = {
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Maps the output for each bundled root file
|
||||
* @param {object} format - defined output format from options
|
||||
* @param {string} parsedRootFiles - specified version of the process
|
||||
* @returns {object} - { rootFile: { path }, bundledContent }
|
||||
*/
|
||||
mapBundleOutput(format, parsedRootFiles) {
|
||||
return (contentAndComponents) => {
|
||||
let bundledFile = contentAndComponents.fileContent;
|
||||
bundledFile.components = contentAndComponents.components;
|
||||
if (!format) {
|
||||
let rootFormat = parsedRootFiles.find((inputRoot) => {
|
||||
return inputRoot.fileName === contentAndComponents.fileName;
|
||||
}).parsed.inputFormat;
|
||||
if (rootFormat.toLowerCase() === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
}
|
||||
else if (format.toLowerCase() === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
return { rootFile: { path: parsedRootFiles[0].fileName }, bundledContent: bundledFile };
|
||||
};
|
||||
},
|
||||
|
||||
/*
|
||||
*
|
||||
* @description Takes in parsed root files and bundle it
|
||||
* @param {object} parsedRootFiles - found parsed root files
|
||||
* @param {array} inputData - file data information [{path, content}]
|
||||
@@ -4856,14 +4880,7 @@ module.exports = {
|
||||
return bundleData;
|
||||
});
|
||||
|
||||
let bundleData = data.map((contentAndComponents) => {
|
||||
let bundledFile = contentAndComponents.fileContent;
|
||||
bundledFile.components = contentAndComponents.components;
|
||||
if (format === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
return { rootFile: { path: parsedRootFiles[0].fileName }, bundledContent: bundledFile };
|
||||
});
|
||||
let bundleData = data.map(this.mapBundleOutput(format, parsedRootFiles));
|
||||
|
||||
return bundleData;
|
||||
},
|
||||
@@ -4887,11 +4904,11 @@ module.exports = {
|
||||
let parsedContent = this.parseFileOrThrow(rootFile.content);
|
||||
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
|
||||
}).filter((rootWithParsedContent) => {
|
||||
bundleFormat = bundleFormat ? bundleFormat : rootWithParsedContent.parsed.inputFormat;
|
||||
// bundleFormat = bundleFormat ? bundleFormat : rootWithParsedContent.parsed.inputFormat;
|
||||
return compareVersion(version, rootWithParsedContent.parsed.oasObject.openapi);
|
||||
}),
|
||||
data = toBundle ?
|
||||
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat.toLowerCase()) :
|
||||
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat) :
|
||||
this.getRelatedFilesData(parsedRootFiles, inputData, origin);
|
||||
return data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user