Skip to content

Commit

Permalink
Add excludeFiles to avoid failing script
Browse files Browse the repository at this point in the history
Changes:

- added the function temporarily to avoid validation failure
  due to these two files

- The schemas version are incorrect in these and needs to be fixed

Issue concerning fixing of the described issue:
1. asyncapi#454
2. asyncapi#455
  • Loading branch information
AnimeshKumar923 committed Nov 28, 2023
1 parent 17fcffd commit b819893
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions scripts/validate-schemas-final.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ajvDraft04 = new AjvDraft04();
const Ajv = require('ajv');
const ajv = new Ajv();

function validation (){
function validation (excludedFiles){

// Specify the path to the 'schemas' directory
const directoryPath = './schemas';
Expand All @@ -17,7 +17,7 @@ function validation (){
const files = fs.readdirSync(directoryPath);

// Filter files
const filteredFiles = files.filter(file => path.extname(file).toLowerCase() === '.json');
const filteredFiles = files.filter(file => !excludedFiles.includes(file) && path.extname(file).toLowerCase() === '.json');


// Collect errors in an array
Expand All @@ -39,13 +39,13 @@ function validation (){
// Validate the schema
validate = ajvDraft04.validateSchema(obj);
if(validate){
console.log(`${file}: JSON Schema is valid!`);
console.log(`\n${file}: JSON Schema is valid!`);
}
} else {
// Validate the schema
validate = ajv.validateSchema(obj);
if(validate){
console.log(`${file}: JSON Schema is valid!`);
console.log(`\n${file}: JSON Schema is valid!`);
}
}

Expand All @@ -62,14 +62,14 @@ function validation (){
} catch (error) {
validationErrors.push({
file,
errors: [{ message: `Error reading or parsing JSON Schema: ${error.message}` }]
errors: [{ message: `\nError reading or parsing JSON Schema: ${error.message}` }]
});
}
});

// Print errors after processing all files
validationErrors.forEach(({ file, errors }) => {
console.error(`${file}: JSON Schema is not valid:`, errors);
console.error(`\n${file}: JSON Schema is not valid:`, errors);
});

// Exit with an error code if there are validation errors
Expand All @@ -78,10 +78,13 @@ function validation (){
}

} catch (error) {
console.error('Error during validation:', error.message);
console.error('\nError during validation:', error.message);
}
}


validation();
console.log('Validation completed successfully.');
const excludedFiles=['2.0.0-rc1.json', '2.0.0-rc1-without-$id.json']; // added temporarily to avoid validation failure due to these two files. The schemas version are incorrect in these and needs to be fixed.

validation(excludedFiles);

console.log('\nValidation completed successfully.');

0 comments on commit b819893

Please sign in to comment.