MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / validateRegistryConsistency

Function validateRegistryConsistency

tests/schema-validation.test.cjs:169–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167}
168
169function validateRegistryConsistency() {
170 const registryPath = path.join(SCHEMA_BASE_DIR, 'index.json');
171 const registry = loadSchema(registryPath);
172
173 // Collect all schema references from the registry
174 const registryRefs = new Set();
175
176 function collectRefs(obj) {
177 if (typeof obj === 'object' && obj !== null) {
178 if (obj.$ref) {
179 registryRefs.add(obj.$ref);
180 }
181 for (const value of Object.values(obj)) {
182 collectRefs(value);
183 }
184 }
185 }
186
187 collectRefs(registry);
188
189 // Find all actual schemas
190 const actualSchemas = findAllSchemas(SCHEMA_BASE_DIR);
191 const actualSchemaIds = actualSchemas
192 .map(schemaPath => loadSchema(schemaPath).$id);
193
194 // Check that all registry references exist
195 const missingSchemas = [];
196 for (const ref of registryRefs) {
197 if (!actualSchemaIds.includes(ref)) {
198 missingSchemas.push(ref);
199 }
200 }
201
202 if (missingSchemas.length > 0) {
203 return `Registry references missing schemas: ${missingSchemas.join(', ')}`;
204 }
205
206 return true;
207}
208
209// Main test execution
210async function runTests() {

Callers 1

runTestsFunction · 0.85

Calls 3

collectRefsFunction · 0.85
findAllSchemasFunction · 0.85
loadSchemaFunction · 0.70

Tested by

no test coverage detected