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

Function lintSchemas

scripts/lint-pagination-invariant.cjs:129–158  ·  view source on GitHub ↗
(dir = SCHEMA_DIR)

Source from the content-addressed store, hash-verified

127}
128
129function lintSchemas(dir = SCHEMA_DIR) {
130 const violations = [];
131 for (const file of walkFiles(dir, ['.json'])) {
132 let doc;
133 try {
134 doc = JSON.parse(fs.readFileSync(file, 'utf8'));
135 } catch {
136 continue;
137 }
138 if (!doc || !Array.isArray(doc.examples)) continue;
139 for (let i = 0; i < doc.examples.length; i++) {
140 const example = doc.examples[i];
141 // Schema example shape varies: some wrap payloads in `{ description, data }`,
142 // others place the payload directly in the array element.
143 const data =
144 example && typeof example === 'object' && 'data' in example ? example.data : example;
145 for (const found of walkPaginationObjects(data)) {
146 const violation = checkPagination(found.pagination);
147 if (violation) {
148 violations.push({
149 file: path.relative(REPO_ROOT, file),
150 location: `examples[${i}].${found.pathSoFar.join('.')}`,
151 rule: violation.rule,
152 });
153 }
154 }
155 }
156 }
157 return violations;
158}
159
160function lintStoryboards(dir = STORYBOARD_DIR) {
161 const violations = [];

Callers 2

lintFunction · 0.85

Calls 3

walkFilesFunction · 0.85
walkPaginationObjectsFunction · 0.85
checkPaginationFunction · 0.85

Tested by

no test coverage detected