use of com.manydesigns.portofino.dispatcher.visitor.DepthFirstVisitor in project Portofino by ManyDesigns.
the class DocumentedApiRoot method afterScan.
@Override
public void afterScan(OpenApiReader reader, OpenAPI openAPI) {
final SubResourceReader subResourceReader = getSubResourceReader(openAPI);
try {
// TODO actions should be put in a special "inspection mode" to avoid checks (e.g. not-in-use-case),
// hitting the DB or services, etc.
Resource root = rootFactory.createRoot();
root.setResourceContext(getResourceContext());
initRoot(root);
if (openAPI.getPaths() == null) {
openAPI.setPaths(new Paths());
}
new DepthFirstVisitor(node -> {
try {
OpenAPI subApi = subResourceReader.readSubResource(node);
openAPI.getPaths().putAll(subApi.getPaths());
// TODO merge components too
} catch (Exception e) {
logger.error("Could not read node at " + node.getLocation(), e);
}
}).visit(root);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
Aggregations