Added test for 31x

Added test for 31x
This commit is contained in:
Luis Tejeda
2021-11-25 12:11:32 -06:00
committed by Erik Mendoza
parent 0be5fb9a75
commit d6fa8832eb
11 changed files with 276 additions and 17 deletions

View File

@@ -21,12 +21,29 @@ const COLLECTION_NAME = 'Imported from OpenAPI 3.0',
// This provides the base class for
// errors with the input OpenAPI spec
OpenApiErr = require('./error.js');
OpenApiErr = require('./error.js'),
DEFAULT_SPEC_VERSION = '3.0';
let path = require('path'),
schemaUtils,
pathBrowserify = require('path-browserify');
/**
*
* @param {string} specVersion - the OAS specification version
* @returns {NodeRequire} the schema utils according to version
*/
function getConcreteSchemaUtils(specVersion) {
let schemaUtils = {};
if (specVersion === DEFAULT_SPEC_VERSION) {
schemaUtils = require('./schemaUtils');
}
else {
schemaUtils = require('./schemaUtils31X');
}
return schemaUtils;
}
class SchemaPack {
constructor (input, options = {}) {
this.input = input;
@@ -49,14 +66,7 @@ class SchemaPack {
let indentCharacter = this.computedOptions.indentCharacter,
specVersion = '3.0';// Get real version
this.computedOptions.indentCharacter = indentCharacter === 'tab' ? '\t' : ' ';
if (specVersion === '3.0') {
schemaUtils = require('./schemaUtils');
}
else {
schemaUtils = require('./schemaUtils31X');
}
schemaUtils = getConcreteSchemaUtils(specVersion);
this.validate();
}
@@ -194,7 +204,7 @@ class SchemaPack {
}
try {
rootFiles = parse.getRootFiles(input, files);
rootFiles = parse.getRootFiles(input, schemaUtils.inputValidation, files);
}
catch (e) {
return cb(null, {