Folder for multifile and multi data res

Change the use of folder and now use multiFile as option type value.
Return a JS object instead of a json string
return a data array in response
This commit is contained in:
Luis Tejeda
2022-06-06 17:14:08 -05:00
parent 4ccfa86271
commit 0a81fd8a96
6 changed files with 134 additions and 79 deletions

View File

@@ -167,7 +167,7 @@ function getSpecVersion({ type, data, specificationVersion }) {
return DEFAULT_SPEC_VERSION;
}
if (['folder'].includes(type)) {
if (['folder', 'multiFile'].includes(type)) {
data = getFileWithVersion(data, specificationVersion);
}
else if (['file'].includes(type)) {

View File

@@ -4854,15 +4854,17 @@ module.exports = {
let bundleData = getBundleContentAndComponents(root, inputData, origin);
return bundleData;
});
let bundledFile = data[0].fileContent;
bundledFile.components = data[0].components;
if (format === parse.YAML_FORMAT) {
bundledFile = parse.toYAML(bundledFile);
}
else if (format === parse.JSON_FORMAT) {
bundledFile = parse.toJSON(bundledFile, 2);
}
return { rootFile: { path: parsedRootFiles[0].fileName }, bundledContent: bundledFile };
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 };
});
return bundleData;
},
/**

View File

@@ -31,11 +31,10 @@ const COLLECTION_NAME = 'Imported from OpenAPI 3.0',
let path = require('path'),
concreteUtils,
pathBrowserify = require('path-browserify');
// traverseUtility = require('traverse');
class SchemaPack {
constructor (input, options = {}) {
if (input.type === 'folder' && input.data && input.data[0] && input.data[0].path) {
if (input.type === 'multiFile' && input.data && input.data[0] && input.data[0].path) {
input = schemaUtils.mapDetectRootFilesInputToFolderInput(input);
}
this.input = input;