(document, name)
| 72 | |
| 73 | // Function to validate a document using AsyncAPI parser |
| 74 | async function validateParser(document, name) { |
| 75 | try { |
| 76 | const diagnostics = await parser.validate(document); |
| 77 | |
| 78 | // Ignore asyncapi-latest-version diagnostic - not relevant to this test and would require updating version each release |
| 79 | const filteredDiagnostics = diagnostics.filter(d => d.code !== 'asyncapi-latest-version'); |
| 80 | |
| 81 | if (filteredDiagnostics.length > 0) { |
| 82 | filteredDiagnostics.forEach(diagnostic => { |
| 83 | |
| 84 | const errorMessage = `\x1b[31mError in ${name}: ${diagnostic.message}\x1b[0m`; |
| 85 | if (diagnostic.level === 'error') { |
| 86 | console.error(errorMessage); |
| 87 | process.exit(1); |
| 88 | } else { |
| 89 | console.log(errorMessage); |
| 90 | } |
| 91 | }); |
| 92 | } else { |
| 93 | console.log(`${name} is valid.`); |
| 94 | } |
| 95 | } catch (error) { |
| 96 | console.error(`\x1b[31mValidation failed for ${name}: ${error.message}\x1b[0m`); |
| 97 | process.exit(1); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // Iterate over the combinedData array, apply updates, and validate each document |
| 102 | const baseDocPath = './base-doc-combined.json'; |
no outgoing calls
no test coverage detected
searching dependent graphs…