| 98 | } |
| 99 | |
| 100 | function validateSchemaStructure(schemaPath, schema) { |
| 101 | // Check required top-level fields |
| 102 | if (!schema.$schema) { |
| 103 | return 'Missing $schema field'; |
| 104 | } |
| 105 | |
| 106 | if (!schema.$id) { |
| 107 | return 'Missing $id field'; |
| 108 | } |
| 109 | |
| 110 | if (!schema.title) { |
| 111 | return 'Missing title field'; |
| 112 | } |
| 113 | |
| 114 | if (!schema.description) { |
| 115 | return 'Missing description field'; |
| 116 | } |
| 117 | |
| 118 | // Validate $schema format |
| 119 | if (!schema.$schema.startsWith('http://json-schema.org/')) { |
| 120 | return 'Invalid $schema URL format'; |
| 121 | } |
| 122 | |
| 123 | // Validate $id format (should be relative path) |
| 124 | if (!schema.$id.startsWith('/schemas/')) { |
| 125 | return `Invalid $id format: ${schema.$id} (should start with /schemas/)`; |
| 126 | } |
| 127 | |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | function validateCrossReferences(schemas) { |
| 132 | const schemaIds = new Set(schemas.map(([_, schema]) => schema.$id)); |