use of org.springdoc.core.annotations.RouterOperations 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);
}
}
}
use of org.springdoc.core.annotations.RouterOperations in project springdoc-openapi by springdoc.
the class SpringCloudFunctionProvider method getRouterFunctionPaths.
/**
* Gets router function paths.
*
* @param beanName the bean name
* @return the router function paths
*/
protected RouterOperation getRouterFunctionPaths(String beanName, RequestMethod requestMethod) {
RouterOperations routerOperations = applicationContext.findAnnotationOnBean(beanName, RouterOperations.class);
RouterOperation routerOperationResult = null;
if (routerOperations == null) {
org.springdoc.core.annotations.RouterOperation routerOperation = applicationContext.findAnnotationOnBean(beanName, org.springdoc.core.annotations.RouterOperation.class);
if (routerOperation != null)
routerOperationResult = new RouterOperation(routerOperation);
} else {
org.springdoc.core.annotations.RouterOperation[] routerOperationArray = routerOperations.value();
if (ArrayUtils.isNotEmpty(routerOperationArray)) {
if (routerOperationArray.length == 1)
routerOperationResult = new RouterOperation(routerOperationArray[0]);
else {
Optional<org.springdoc.core.annotations.RouterOperation> routerOperationOptional = Arrays.stream(routerOperationArray).filter(routerOperation -> Arrays.asList(routerOperation.method()).contains(requestMethod)).findAny();
if (routerOperationOptional.isPresent())
routerOperationResult = new RouterOperation(routerOperationOptional.get(), requestMethod);
}
}
}
return routerOperationResult;
}
Aggregations