use of org.springdoc.core.fn.AbstractRouterFunctionVisitor in project springdoc-openapi by springdoc.
the class RouterFunctionWebMvcProvider method getRouterFunctionPaths.
/**
* Gets web mvc router function paths.
*
* @return the web mvc router function paths
*/
public Optional<Map<String, AbstractRouterFunctionVisitor>> getRouterFunctionPaths() {
Map<String, RouterFunction> routerBeans = applicationContext.getBeansOfType(RouterFunction.class);
if (CollectionUtils.isEmpty(routerBeans))
return Optional.empty();
Map<String, AbstractRouterFunctionVisitor> routerFunctionVisitorMap = new HashMap<>();
for (Map.Entry<String, RouterFunction> entry : routerBeans.entrySet()) {
RouterFunction routerFunction = entry.getValue();
RouterFunctionVisitor routerFunctionVisitor = new RouterFunctionVisitor();
routerFunction.accept(routerFunctionVisitor);
routerFunctionVisitorMap.put(entry.getKey(), routerFunctionVisitor);
}
return Optional.of(routerFunctionVisitorMap);
}
use of org.springdoc.core.fn.AbstractRouterFunctionVisitor in project springdoc-openapi by springdoc.
the class AbstractOpenApiResource method getRouterFunctionPaths.
/**
* Gets router function paths.
*
* @param beanName the bean name
* @param routerFunctionVisitor the router function visitor
* @param locale the locale
*/
protected void getRouterFunctionPaths(String beanName, AbstractRouterFunctionVisitor routerFunctionVisitor, Locale locale) {
boolean withRouterOperation = routerFunctionVisitor.getRouterFunctionDatas().stream().anyMatch(routerFunctionData -> routerFunctionData.getAttributes().containsKey(OPERATION_ATTRIBUTE));
if (withRouterOperation) {
List<RouterOperation> operationList = routerFunctionVisitor.getRouterFunctionDatas().stream().map(RouterOperation::new).collect(Collectors.toList());
calculatePath(operationList, locale);
} else {
List<org.springdoc.core.annotations.RouterOperation> routerOperationList = new ArrayList<>();
ApplicationContext applicationContext = openAPIService.getContext();
RouterOperations routerOperations = applicationContext.findAnnotationOnBean(beanName, RouterOperations.class);
if (routerOperations == null) {
org.springdoc.core.annotations.RouterOperation routerOperation = applicationContext.findAnnotationOnBean(beanName, org.springdoc.core.annotations.RouterOperation.class);
if (routerOperation != null)
routerOperationList.add(routerOperation);
} else
routerOperationList.addAll(Arrays.asList(routerOperations.value()));
if (routerOperationList.size() == 1)
calculatePath(routerOperationList.stream().map(routerOperation -> new RouterOperation(routerOperation, routerFunctionVisitor.getRouterFunctionDatas().get(0))).collect(Collectors.toList()), locale);
else {
List<RouterOperation> operationList = routerOperationList.stream().map(RouterOperation::new).collect(Collectors.toList());
mergeRouters(routerFunctionVisitor.getRouterFunctionDatas(), operationList);
calculatePath(operationList, locale);
}
}
}
Aggregations