File tree 3 files changed +136
-6
lines changed
springdoc-openapi-common/src/main/java/org/springdoc/core/converters
springdoc-openapi-webmvc-core/src/test
java/test/org/springdoc/api/app59
3 files changed +136
-6
lines changed Original file line number Diff line number Diff line change 21
21
package org .springdoc .core .converters ;
22
22
23
23
import java .lang .annotation .Annotation ;
24
- import java .lang .reflect .AnnotatedElement ;
24
+ import java .lang .reflect .Method ;
25
25
import java .util .ArrayList ;
26
26
import java .util .Iterator ;
27
27
import java .util .List ;
@@ -82,10 +82,13 @@ public static void addDeprecatedType(Class<? extends Annotation> cls) {
82
82
/**
83
83
* Is deprecated boolean.
84
84
*
85
- * @param annotatedElement the annotated element
85
+ * @param method the annotated element
86
86
* @return the boolean
87
87
*/
88
- public static boolean isDeprecated (AnnotatedElement annotatedElement ) {
89
- return DEPRECATED_ANNOTATIONS .stream ().anyMatch (annoClass -> AnnotatedElementUtils .findMergedAnnotation (annotatedElement , annoClass ) != null );
88
+ public static boolean isDeprecated (Method method ) {
89
+ Class <?> declaringClass = method .getDeclaringClass ();
90
+ boolean deprecatedMethod = DEPRECATED_ANNOTATIONS .stream ().anyMatch (annoClass -> AnnotatedElementUtils .findMergedAnnotation (method , annoClass ) != null );
91
+ boolean deprecatedClass = DEPRECATED_ANNOTATIONS .stream ().anyMatch (annoClass -> AnnotatedElementUtils .findMergedAnnotation (declaringClass , annoClass ) != null );
92
+ return deprecatedClass || deprecatedMethod ;
90
93
}
91
94
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ *
3
+ * * Copyright 2019-2020 the original author or authors.
4
+ * *
5
+ * * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * * you may not use this file except in compliance with the License.
7
+ * * You may obtain a copy of the License at
8
+ * *
9
+ * * https://www.apache.org/licenses/LICENSE-2.0
10
+ * *
11
+ * * Unless required by applicable law or agreed to in writing, software
12
+ * * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * * See the License for the specific language governing permissions and
15
+ * * limitations under the License.
16
+ *
17
+ */
18
+
19
+ package test .org .springdoc .api .app59 ;
20
+
21
+ import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
22
+
23
+ import org .springframework .validation .annotation .Validated ;
24
+ import org .springframework .web .bind .annotation .GetMapping ;
25
+ import org .springframework .web .bind .annotation .PostMapping ;
26
+ import org .springframework .web .bind .annotation .RequestBody ;
27
+ import org .springframework .web .bind .annotation .RestController ;
28
+
29
+ @ RestController
30
+ @ Deprecated
31
+ public class HelloController2 {
32
+
33
+ @ GetMapping ("/example2" )
34
+ public void test () {
35
+ }
36
+
37
+ @ PostMapping ("/hello2" )
38
+ @ ApiResponse (responseCode = "200" , description = "The server accepted your hello." )
39
+ String hello (@ Validated @ RequestBody final HelloBody helloBody ) {
40
+ return "World!" ;
41
+ }
42
+ }
Original file line number Diff line number Diff line change 28
28
"required" : true
29
29
},
30
30
"responses" : {
31
+ "400" : {
32
+ "description" : " The request is malformed or information is missing." ,
33
+ "content" : {
34
+ "*/*" : {
35
+ "schema" : {
36
+ "type" : " object"
37
+ }
38
+ }
39
+ }
40
+ },
31
41
"500" : {
32
42
"description" : " An unknown error occurred" ,
33
43
"content" : {
38
48
}
39
49
}
40
50
},
51
+ "200" : {
52
+ "description" : " The server accepted your hello." ,
53
+ "content" : {
54
+ "*/*" : {
55
+ "schema" : {
56
+ "type" : " string"
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ },
64
+ "/hello2" : {
65
+ "post" : {
66
+ "tags" : [
67
+ " hello-controller-2"
68
+ ],
69
+ "operationId" : " hello_1" ,
70
+ "requestBody" : {
71
+ "content" : {
72
+ "application/json" : {
73
+ "schema" : {
74
+ "$ref" : " #/components/schemas/HelloBody"
75
+ }
76
+ }
77
+ },
78
+ "required" : true
79
+ },
80
+ "responses" : {
41
81
"400" : {
42
82
"description" : " The request is malformed or information is missing." ,
43
83
"content" : {
48
88
}
49
89
}
50
90
},
91
+ "500" : {
92
+ "description" : " An unknown error occurred" ,
93
+ "content" : {
94
+ "*/*" : {
95
+ "schema" : {
96
+ "type" : " object"
97
+ }
98
+ }
99
+ }
100
+ },
51
101
"200" : {
52
102
"description" : " The server accepted your hello." ,
53
103
"content" : {
58
108
}
59
109
}
60
110
}
61
- }
111
+ },
112
+ "deprecated" : true
62
113
}
63
114
},
64
115
"/example" : {
68
119
],
69
120
"operationId" : " test" ,
70
121
"responses" : {
122
+ "400" : {
123
+ "description" : " The request is malformed or information is missing." ,
124
+ "content" : {
125
+ "*/*" : {
126
+ "schema" : {
127
+ "type" : " object"
128
+ }
129
+ }
130
+ }
131
+ },
71
132
"500" : {
72
133
"description" : " An unknown error occurred" ,
73
134
"content" : {
78
139
}
79
140
}
80
141
},
142
+ "200" : {
143
+ "description" : " OK"
144
+ }
145
+ },
146
+ "deprecated" : true
147
+ }
148
+ },
149
+ "/example2" : {
150
+ "get" : {
151
+ "tags" : [
152
+ " hello-controller-2"
153
+ ],
154
+ "operationId" : " test_1" ,
155
+ "responses" : {
81
156
"400" : {
82
157
"description" : " The request is malformed or information is missing." ,
83
158
"content" : {
88
163
}
89
164
}
90
165
},
166
+ "500" : {
167
+ "description" : " An unknown error occurred" ,
168
+ "content" : {
169
+ "*/*" : {
170
+ "schema" : {
171
+ "type" : " object"
172
+ }
173
+ }
174
+ }
175
+ },
91
176
"200" : {
92
177
"description" : " OK"
93
178
}
111
196
}
112
197
}
113
198
}
114
- }
199
+ }
You can’t perform that action at this time.
0 commit comments