in schema-induction/src/main/java/aws/json/schema/induction/JsonSchemaGenerator.java [42:85]
private ObjectNode generateCurrent(SchemaNode current, JsonNode typeChild) {
ObjectNode newSchemaNode = generateBasicAttributes(current);
ObjectNode childNodes = JsonNodeFactory.instance.objectNode();
newSchemaNode.set("class", typeChild);
if (current.getChildren().isEmpty())
return newSchemaNode;
newSchemaNode.set("children", childNodes);
for (SchemaNode child : current.getChildren()) {
JsonNode properties = typeChild.get("properties");
if (properties != null) {
String localName = child.getLocalName();
JsonNode property = properties.get(localName);
if (property == null) {
ObjectNode childJsonNode = generateCurrentWithoutSchema(child);
childNodes.set(localName,childJsonNode);
continue;
}
JsonNode items = property.get("items");
JsonNode ref = property.get("$ref");
if (ref != null) {
String childKey = ref.asText();
JsonNode schemaNodeDefinition = schema.getRefSchemaNode(childKey);
ObjectNode childJsonNode = generateCurrent(child, schemaNodeDefinition);
childJsonNode.set("description",property.get("description"));
childNodes.set(localName,childJsonNode);
} else if (items != null) {
ref = items.get("$ref");
String childKey = ref.asText();
JsonNode schemaNodeDefinition = schema.getRefSchemaNode(childKey);
ObjectNode childJsonNode = generateCurrent(child, schemaNodeDefinition);
childJsonNode.set("description",property.get("description"));
childNodes.set(localName,childJsonNode);
} else {
// skip we already added all details to a leaf node
}
} else {
// skip we already added all details to a leaf node
}
}
return newSchemaNode;
}