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 @@ -222,9 +222,38 @@ private Set<String> recurseIntoProperty(
if (itemResolved != null) {
JsonNode itemFlat = flattenAllOf(itemResolved, root, visited);
JsonNode itemType = itemFlat.get(TYPE_KEY);
if (itemType != null && itemType.asText().equals(OBJECT_KEY)) {
boolean isObjectLike =
(itemType != null && itemType.asText().equals(OBJECT_KEY))
|| (itemType == null
&& (itemFlat.has(PROPERTIES_KEY)
|| itemFlat.has(REQUIRED_KEY)));
if (isObjectLike) {
paths.addAll(
extractRequiredPaths(itemFlat, root, fullPath + "[]", visited));
} else {
// oneOf/anyOf into items
String choiceKey =
itemFlat.has(ONE_OF_KEY)
? ONE_OF_KEY
: itemFlat.has(ANY_OF_KEY) ? ANY_OF_KEY : null;
if (choiceKey != null) {
for (JsonNode variant : itemFlat.get(choiceKey)) {
Set<JsonNode> variantVisited =
Collections.newSetFromMap(new IdentityHashMap<>());
variantVisited.addAll(visited);
JsonNode varResolved =
resolveRefSafe(variant, root, variantVisited);
if (varResolved == null) continue;
JsonNode varFlat =
flattenAllOf(varResolved, root, variantVisited);
paths.addAll(
extractRequiredPaths(
varFlat,
root,
fullPath + "[]",
variantVisited));
}
}
}
}
}
Expand Down
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(111, schema.getRequiredPaths().size());
assertEquals(166, schema.getRequiredPaths().size());
assertFalse(schema.isHasVariants());
assertEquals(0, schema.getPatternProperties().size());
}
Expand Down
Loading