@@ -85,11 +85,16 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
85
85
86
86
private static final List <Class <?>> ADDITIONAL_REST_CONTROLLERS = new ArrayList <>();
87
87
private static final List <Class <?>> HIDDEN_REST_CONTROLLERS = new ArrayList <>();
88
+ private static final List <Class > DEPRECATED_TYPES = new ArrayList <>();
88
89
89
90
private boolean computeDone ;
90
91
91
92
private final String groupName ;
92
93
94
+ static {
95
+ DEPRECATED_TYPES .add (Deprecated .class );
96
+ }
97
+
93
98
protected AbstractOpenApiResource (String groupName , OpenAPIBuilder openAPIBuilder , AbstractRequestBuilder requestBuilder ,
94
99
GenericResponseBuilder responseBuilder , OperationBuilder operationParser ,
95
100
Optional <List <OpenApiCustomiser >> openApiCustomisers , SpringDocConfigProperties springDocConfigProperties ) {
@@ -177,7 +182,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
177
182
178
183
Operation operation = (existingOperation != null ) ? existingOperation : new Operation ();
179
184
180
- if (ReflectionUtils . getAnnotation (method , Deprecated . class ) != null ) {
185
+ if (isDeprecatedType (method ) ) {
181
186
operation .setDeprecated (true );
182
187
}
183
188
@@ -394,4 +399,12 @@ protected Set getDefaultAllowedHttpMethods() {
394
399
RequestMethod [] allowedRequestMethods = { RequestMethod .GET , RequestMethod .POST , RequestMethod .PUT , RequestMethod .PATCH , RequestMethod .DELETE , RequestMethod .OPTIONS , RequestMethod .HEAD };
395
400
return new HashSet <>(Arrays .asList (allowedRequestMethods ));
396
401
}
402
+
403
+ public static void addDeprecatedType (Class <?> cls ){
404
+ DEPRECATED_TYPES .add (cls );
405
+ }
406
+
407
+ private boolean isDeprecatedType (Method method ) {
408
+ return DEPRECATED_TYPES .stream ().anyMatch (clazz -> (ReflectionUtils .getAnnotation (method , clazz ) != null ));
409
+ }
397
410
}
0 commit comments