Skip to content

Commit 0e25aed

Browse files
authored
feat: implement dependentSchemas keyword handler for graph visualization (ioflux-org#346)
Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
1 parent 107f64d commit 0e25aed

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"json-schema-studio": minor
3+
---
4+
5+
Implement `dependentSchemas` keyword handler in graph visualization
6+
7+
Properties with `dependentSchemas` now render as connected child nodes in the graph, making schema dependencies visually explorable.

‎src/utils/processAST.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,13 @@ const keywordHandlerMap: KeywordHandlerMap = {
351351
}
352352
return { key: "patternProperties", data: { value: getArrayFromNumber(value.length) } }
353353
},
354-
// "https://json-schema.org/keyword/dependentSchemas": createBasicKeywordHandler("dependentSchemas"),
354+
"https://json-schema.org/keyword/dependentSchemas": (ast, keywordValue, nodes, edges, parentId, nodeDepth, renderedNodes) => {
355+
const value = keywordValue as [string, string][];
356+
for (const [propertyName, schemaUri] of value) {
357+
processAST({ ast, schemaUri, nodes, edges, parentId, renderedNodes, childId: propertyName, nodeTitle: `dependentSchemas["${propertyName}"]`, nodeDepth });
358+
}
359+
return { key: "dependentSchemas", data: { value: value.map(([propertyName]) => propertyName) } };
360+
},
355361
"https://json-schema.org/keyword/contains": (ast, keywordValue, nodes, edges, parentId, nodeDepth, renderedNodes) => {
356362
const value = keywordValue as { contains: string; minContains: number; maxContains: number };
357363
processAST({ ast, schemaUri: value.contains, nodes, edges, parentId, childId: "contains", renderedNodes, nodeTitle: "contains", nodeDepth });

0 commit comments

Comments
 (0)