@@ -83,6 +83,7 @@ public abstract class AbstractOpenApiResource {
83
83
private final SpringDocConfigProperties springDocConfigProperties ;
84
84
85
85
private static final List <Class <?>> ADDITIONAL_REST_CONTROLLERS = new ArrayList <>();
86
+ private static final List <Class <?>> HIDDEN_REST_CONTROLLERS = new ArrayList <>();
86
87
87
88
private boolean computeDone ;
88
89
@@ -113,6 +114,7 @@ protected synchronized OpenAPI getOpenApi() {
113
114
.flatMap (mapEl -> mapEl .entrySet ().stream ())
114
115
.filter (controller -> (AnnotationUtils .findAnnotation (controller .getValue ().getClass (),
115
116
Hidden .class ) == null ))
117
+ .filter (controller -> !isHiddenRestControllers (controller .getValue ().getClass ()))
116
118
.collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue , (a1 , a2 ) -> a1 ));
117
119
118
120
Map <String , Object > findControllerAdvice = openAPIBuilder .getControllerAdviceMap ();
@@ -358,6 +360,13 @@ public static void addRestControllers(Class<?>... classes) {
358
360
ADDITIONAL_REST_CONTROLLERS .addAll (Arrays .asList (classes ));
359
361
}
360
362
363
+ public static void addHiddenRestControllers (Class <?>... classes ) {
364
+ HIDDEN_REST_CONTROLLERS .addAll (Arrays .asList (classes ));
365
+ }
366
+ protected boolean isHiddenRestControllers (Class <?> rawClass ) {
367
+ return HIDDEN_REST_CONTROLLERS .stream ().anyMatch (clazz -> clazz .isAssignableFrom (rawClass ));
368
+ }
369
+
361
370
protected Set getDefaultAllowedHttpMethods () {
362
371
RequestMethod [] allowedRequestMethods = { RequestMethod .GET , RequestMethod .POST , RequestMethod .PUT , RequestMethod .PATCH , RequestMethod .DELETE , RequestMethod .OPTIONS , RequestMethod .HEAD };
363
372
return new HashSet <>(Arrays .asList (allowedRequestMethods ));
0 commit comments