-
-
Notifications
You must be signed in to change notification settings - Fork 553
Description
Is your feature request related to a problem? Please describe.
We are implementing many management endpoints as custom actuators and we would like to group them (right now, there are > 70 actuators in the list). Currently, adding an @Tag annotation does not work, because all actuators are grouped together in a single, hardcoded group.
Describe the solution you'd like
As far as I can see it, the code in OpenApiResource has access to each method representing an actuator endpoint as part of the HandlerMethod object. So maybe the method could check for the existence of a tag like this(untested code)?
Map<Tag, List<HandlerMethod>> tagMappings = new HashMap<>();
//check for Tag annotation existance
for (HandlerMethod method : actuatorMap.values()) {
Class<?> beanType = method.getBeanType();
io.swagger.v3.oas.annotations.tags.Tag t = beanType.getAnnotation(io.swagger.v3.oas.annotations.tags.Tag.class);
if(t != null) {
//use configured tag
Tag tag = new Tag()
.description(t.description())
.name(t.name());
tagMappings.computeIfAbsent(tag, k -> new java.util.ArrayList<>()).add(method);
}else{
//use default tag
tagMappings.computeIfAbsent(getTag(), k-> new java.util.ArrayList<>()).add(method);
}
}
//add actuators by tags
tagMappings.entrySet().forEach(kvp -> {
this.openAPIService.addTag(new HashSet<>(kvp.getValue()), kvp.getKey());
});Describe alternatives you've considered
We considered hiding the OOTB actuators from the OpenAPI, but there seems no way to hide them without disabling them or hiding our custom actuators too.