Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,16 @@ private Set<String> extractRequiredPaths(
}

// Traverse non-required properties too to find nested required paths.
// Needed for schemas like AAS where the root has no required fields
// but nested definitions do.
if (propertiesNode != null) {
for (Map.Entry<String, JsonNode> entry : propertiesNode.properties()) {
String propName = entry.getKey();
if (requiredFields.contains(propName)) continue;
String fullPath = currentPath.isEmpty() ? propName : currentPath + "." + propName;
paths.addAll(recurseIntoProperty(entry.getValue(), root, fullPath, visited));
Set<JsonNode> siblingVisited = Collections.newSetFromMap(new IdentityHashMap<>());
siblingVisited.addAll(visited);
paths.addAll(recurseIntoProperty(entry.getValue(), root, fullPath, siblingVisited));
}
}

return paths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public void testJsonPropertyExtraction() throws JsonProcessingException {
props = extractor.extractAllPaths(CommonUtils.readJsonNode("invalid-battery.json"));
assertEquals(42, props.size());
}

@Test
public void testJsonPropertyExtraction2() throws JsonProcessingException {
Set<String> props = extractor.extractAllPaths(CommonUtils.readJsonNode("aas-bike.json"));
assertEquals(64, props.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testExtraction3() {
public void testExtraction4() {
SchemaMetadata schema =
extractor.extractMetadata(CommonUtils.readJsonSchemaNode("test-aas-schema.json"));
assertEquals(16, schema.getRequiredPaths().size());
assertEquals(111, schema.getRequiredPaths().size());
assertFalse(schema.isHasVariants());
assertEquals(0, schema.getPatternProperties().size());
}
Expand Down
Loading
Loading