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

Function validateSchemaStructure

tests/schema-validation.test.cjs:100–129  ·  view source on GitHub ↗
(schemaPath, schema)

Source from the content-addressed store, hash-verified

98}
99
100function 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
131function validateCrossReferences(schemas) {
132 const schemaIds = new Set(schemas.map(([_, schema]) => schema.$id));

Callers 1

runTestsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected