use of org.springdoc.core.providers.ActuatorProvider in project springdoc-openapi by springdoc.
the class AbstractOpenApiResource method getActuatorURI.
/**
* Gets actuator uri.
*
* @param scheme the scheme
* @param host the host
* @return the actuator uri
*/
protected URI getActuatorURI(String scheme, String host) {
final Optional<ActuatorProvider> actuatorProviderOptional = springDocProviders.getActuatorProvider();
URI uri = null;
if (actuatorProviderOptional.isPresent()) {
ActuatorProvider actuatorProvider = actuatorProviderOptional.get();
int port;
String path;
if (ACTUATOR_DEFAULT_GROUP.equals(this.groupName)) {
port = actuatorProvider.getActuatorPort();
path = actuatorProvider.getActuatorPath();
} else {
port = actuatorProvider.getApplicationPort();
path = actuatorProvider.getContextPath();
String mvcServletPath = this.openAPIService.getContext().getBean(Environment.class).getProperty(SPRING_MVC_SERVLET_PATH);
if (StringUtils.isNotEmpty(mvcServletPath))
path = path + mvcServletPath;
}
try {
uri = new URI(StringUtils.defaultIfEmpty(scheme, "http"), null, StringUtils.defaultIfEmpty(host, "localhost"), port, path, null, null);
} catch (URISyntaxException e) {
LOGGER.error("Unable to parse the URL: scheme {}, host {}, port {}, path {}", scheme, host, port, path);
}
}
return uri;
}
use of org.springdoc.core.providers.ActuatorProvider in project springdoc-openapi by springdoc.
the class OpenApiResource method getPaths.
@Override
@SuppressWarnings("unchecked")
protected void getPaths(Map<String, Object> restControllers, Locale locale) {
Optional<SpringWebProvider> springWebProviderOptional = springDocProviders.getSpringWebProvider();
springWebProviderOptional.ifPresent(springWebProvider -> {
Map<RequestMappingInfo, HandlerMethod> map = springWebProvider.getHandlerMethods();
Optional<RepositoryRestResourceProvider> repositoryRestResourceProviderOptional = springDocProviders.getRepositoryRestResourceProvider();
repositoryRestResourceProviderOptional.ifPresent(restResourceProvider -> {
List<RouterOperation> operationList = restResourceProvider.getRouterOperations(openAPIService.getCalculatedOpenAPI(), locale);
calculatePath(operationList, locale);
restResourceProvider.customize(openAPIService.getCalculatedOpenAPI());
Map<RequestMappingInfo, HandlerMethod> mapDataRest = restResourceProvider.getHandlerMethods();
Map<String, Object> requestMappingMap = restResourceProvider.getBasePathAwareControllerEndpoints();
Class[] additionalRestClasses = requestMappingMap.values().stream().map(AopUtils::getTargetClass).toArray(Class[]::new);
AbstractOpenApiResource.addRestControllers(additionalRestClasses);
map.putAll(mapDataRest);
});
Optional<ActuatorProvider> actuatorProviderOptional = springDocProviders.getActuatorProvider();
if (actuatorProviderOptional.isPresent() && springDocConfigProperties.isShowActuator()) {
Map<RequestMappingInfo, HandlerMethod> actuatorMap = actuatorProviderOptional.get().getMethods();
this.openAPIService.addTag(new HashSet<>(actuatorMap.values()), getTag());
map.putAll(actuatorMap);
}
calculatePath(restControllers, map, locale);
});
Optional<SecurityOAuth2Provider> securityOAuth2ProviderOptional = springDocProviders.getSpringSecurityOAuth2Provider();
if (securityOAuth2ProviderOptional.isPresent()) {
SecurityOAuth2Provider securityOAuth2Provider = securityOAuth2ProviderOptional.get();
Map<RequestMappingInfo, HandlerMethod> mapOauth = securityOAuth2Provider.getHandlerMethods();
Map<String, Object> requestMappingMapSec = securityOAuth2Provider.getFrameworkEndpoints();
Class[] additionalRestClasses = requestMappingMapSec.values().stream().map(AopUtils::getTargetClass).toArray(Class[]::new);
AbstractOpenApiResource.addRestControllers(additionalRestClasses);
calculatePath(requestMappingMapSec, mapOauth, locale);
}
springDocProviders.getRouterFunctionProvider().ifPresent(routerFunctions -> routerFunctions.getRouterFunctionPaths().ifPresent(routerBeans -> routerBeans.forEach((beanName, routerFunctionVisitor) -> getRouterFunctionPaths(beanName, routerFunctionVisitor, locale))));
}
Aggregations