mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Adding new tests for 2.0 version
This commit is contained in:
@@ -4828,13 +4828,20 @@ module.exports = {
|
||||
return data;
|
||||
},
|
||||
|
||||
getBundledFileData(parsedRootFiles, inputData, origin, format) {
|
||||
getBundledFileData(parsedRootFiles, inputData, origin, format, version) {
|
||||
const data = parsedRootFiles.map((root) => {
|
||||
let bundleData = getBundleContentAndComponents(root, inputData, origin);
|
||||
let bundleData = getBundleContentAndComponents(root, inputData, origin, version);
|
||||
return bundleData;
|
||||
});
|
||||
let bundledFile = data[0].fileContent;
|
||||
bundledFile.components = data[0].components;
|
||||
if (version === '2.0') {
|
||||
Object.entries(data[0].components).forEach(([key, value]) => {
|
||||
bundledFile[key] = value;
|
||||
});
|
||||
}
|
||||
else {
|
||||
bundledFile.components = data[0].components;
|
||||
}
|
||||
if (format === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
@@ -4863,11 +4870,14 @@ module.exports = {
|
||||
let parsedContent = this.parseFileOrThrow(rootFile.content);
|
||||
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
|
||||
}).filter((rootWithParsedContent) => {
|
||||
let fileVersion = version === '2.0' ?
|
||||
rootWithParsedContent.parsed.oasObject.swagger :
|
||||
rootWithParsedContent.parsed.oasObject.openapi;
|
||||
bundleFormat = bundleFormat ? bundleFormat : rootWithParsedContent.parsed.inputFormat;
|
||||
return compareVersion(version, rootWithParsedContent.parsed.oasObject.openapi);
|
||||
return compareVersion(version, fileVersion);
|
||||
}),
|
||||
data = toBundle ?
|
||||
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat.toLowerCase()) :
|
||||
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat.toLowerCase(), version) :
|
||||
this.getRelatedFilesData(parsedRootFiles, inputData, origin);
|
||||
return data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user