Change defatult version

change the default version from 3.0.0 to 3.0 and validate incorrect input.type value (different than multiFile)
This commit is contained in:
Luis Tejeda
2022-06-08 16:51:56 -05:00
parent c0254456ae
commit bb3a3c00d9
4 changed files with 67 additions and 7 deletions

View File

@@ -92,7 +92,8 @@ const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/sc
{ getRelatedFiles } = require('./relatedFiles'),
{ compareVersion } = require('./common/versionUtils.js'),
parse = require('./parse'),
{ getBundleContentAndComponents } = require('./bundle.js');
{ getBundleContentAndComponents } = require('./bundle.js'),
MULTI_FILE_API_TYPE_ALLOWED_VALUE = 'multiFile';
/* eslint-enable */
// See https://github.com/json-schema-faker/json-schema-faker/tree/master/docs#available-options
@@ -4797,7 +4798,7 @@ module.exports = {
*/
mapGetRootFilesOutputToDetectRootFilesOutput(output, version) {
if (!version) {
version = '3.0.0';
version = '3.0';
}
let adaptedData = output.map((file) => {
return { path: file };
@@ -4906,7 +4907,7 @@ module.exports = {
* @returns {object} root files information and data input
*/
processRelatedFiles(inputRelatedFiles, toBundle = false) {
let version = inputRelatedFiles.specificationVersion ? inputRelatedFiles.specificationVersion : '3.0.0',
let version = inputRelatedFiles.specificationVersion ? inputRelatedFiles.specificationVersion : '3.0',
res = {
result: true,
output: {
@@ -4957,6 +4958,9 @@ module.exports = {
if (!processInput.type) {
throw new Error('"Type" parameter should be provided');
}
if (processInput.type !== MULTI_FILE_API_TYPE_ALLOWED_VALUE) {
throw new Error('"Type" parameter value allowed is ' + MULTI_FILE_API_TYPE_ALLOWED_VALUE);
}
if (!processInput.data || processInput.data.length === 0) {
throw new Error('"Data" parameter should be provided');
}
@@ -4971,6 +4975,6 @@ module.exports = {
throw new ParseError(result.reason);
}
return result;
}
},
MULTI_FILE_API_TYPE_ALLOWED_VALUE
};