MCPcopy
hub / github.com/asyncapi/spec / validateParser

Function validateParser

scripts/validation/embedded-examples-validation.js:74–99  ·  view source on GitHub ↗
(document, name)

Source from the content-addressed store, hash-verified

72
73// Function to validate a document using AsyncAPI parser
74async 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
102const baseDocPath = './base-doc-combined.json';

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…