add multiple versions support

add multiple versions support
This commit is contained in:
Luis Tejeda
2022-04-19 16:41:21 -05:00
committed by Erik Mendoza
parent 36e83721dd
commit 30cc74b720
7 changed files with 342 additions and 28 deletions

View File

@@ -5,7 +5,8 @@ var yaml = require('js-yaml'),
path = require('path'),
pathBrowserify = require('path-browserify'),
resolver = require('oas-resolver-browser'),
yamlParse = require('yaml');
yamlParse = require('yaml'),
{ compareVersion } = require('./common/versionUtils.js');
const BROWSER = 'browser';
module.exports = {
@@ -79,9 +80,10 @@ module.exports = {
* @param {Object} inputValidation Validator according to version
* @param {Object} options computed process options
* @param {Object} files Files map
* @param {string} specificationVersion the string of the desired version
* @return {String} rootFile
*/
getRootFiles: function (input, inputValidation, options, files = {}) {
getRootFiles: function (input, inputValidation, options, files = {}, specificationVersion) {
let rootFilesArray = [],
filesPathArray = input.data,
origin = input.origin || '';
@@ -110,7 +112,14 @@ module.exports = {
throw new Error(obj.reason);
}
if (inputValidation.validateSpec(oasObject, options).result) {
rootFilesArray.push(filePath.fileName);
if (specificationVersion) {
if (compareVersion(specificationVersion, oasObject.openapi)) {
rootFilesArray.push(filePath.fileName);
}
}
else {
rootFilesArray.push(filePath.fileName);
}
}
}
catch (e) {