File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 3 files changed +136
-6
lines changed Original file line number Diff line number Diff line change 2121package org .springdoc .core .converters ;
2222
2323import java .lang .annotation .Annotation ;
24- import java .lang .reflect .AnnotatedElement ;
24+ import java .lang .reflect .Method ;
2525import java .util .ArrayList ;
2626import java .util .Iterator ;
2727import java .util .List ;
@@ -82,10 +82,13 @@ public static void addDeprecatedType(Class<? extends Annotation> cls) {
8282 /**
8383 * Is deprecated boolean.
8484 *
85- * @param annotatedElement the annotated element
85+ * @param method the annotated element
8686 * @return the boolean
8787 */
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 ;
9093 }
9194}
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 2828 "required" : true
2929 },
3030 "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+ },
3141 "500" : {
3242 "description" : " An unknown error occurred" ,
3343 "content" : {
3848 }
3949 }
4050 },
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" : {
4181 "400" : {
4282 "description" : " The request is malformed or information is missing." ,
4383 "content" : {
4888 }
4989 }
5090 },
91+ "500" : {
92+ "description" : " An unknown error occurred" ,
93+ "content" : {
94+ "*/*" : {
95+ "schema" : {
96+ "type" : " object"
97+ }
98+ }
99+ }
100+ },
51101 "200" : {
52102 "description" : " The server accepted your hello." ,
53103 "content" : {
58108 }
59109 }
60110 }
61- }
111+ },
112+ "deprecated" : true
62113 }
63114 },
64115 "/example" : {
68119 ],
69120 "operationId" : " test" ,
70121 "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+ },
71132 "500" : {
72133 "description" : " An unknown error occurred" ,
73134 "content" : {
78139 }
79140 }
80141 },
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" : {
81156 "400" : {
82157 "description" : " The request is malformed or information is missing." ,
83158 "content" : {
88163 }
89164 }
90165 },
166+ "500" : {
167+ "description" : " An unknown error occurred" ,
168+ "content" : {
169+ "*/*" : {
170+ "schema" : {
171+ "type" : " object"
172+ }
173+ }
174+ }
175+ },
91176 "200" : {
92177 "description" : " OK"
93178 }
111196 }
112197 }
113198 }
114- }
199+ }
You can’t perform that action at this time.
0 commit comments