()
| 167 | } |
| 168 | |
| 169 | function 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 |
| 210 | async function runTests() { |
no test coverage detected