File tree Expand file tree Collapse file tree 5 files changed +157
-1
lines changed
springdoc-openapi-common/src/main/java/org/springdoc/core
springdoc-openapi-webmvc-core/src/test
java/test/org/springdoc/api/app108 Expand file tree Collapse file tree 5 files changed +157
-1
lines changed Original file line number Diff line number Diff line change 44
44
import org .apache .commons .lang3 .StringUtils ;
45
45
46
46
import org .springframework .core .MethodParameter ;
47
+ import org .springframework .core .ResolvableType ;
47
48
import org .springframework .core .annotation .AnnotatedElementUtils ;
48
49
import org .springframework .http .HttpStatus ;
49
50
import org .springframework .util .CollectionUtils ;
53
54
import org .springframework .web .method .HandlerMethod ;
54
55
55
56
import static org .springdoc .core .Constants .DEFAULT_DESCRIPTION ;
57
+ import static org .springdoc .core .converters .ConverterUtils .isResponseTypeWrapper ;
56
58
57
59
@ SuppressWarnings ("rawtypes" )
58
60
public class GenericResponseBuilder {
@@ -336,7 +338,7 @@ private boolean isVoid(Type returnType) {
336
338
result = true ;
337
339
else if (returnType instanceof ParameterizedType ) {
338
340
Type [] types = ((ParameterizedType ) returnType ).getActualTypeArguments ();
339
- if (types != null )
341
+ if (types != null && isResponseTypeWrapper ( ResolvableType . forType ( returnType ). getRawClass ()) )
340
342
return isVoid (types [0 ]);
341
343
}
342
344
if (Void .class .equals (returnType ))
Original file line number Diff line number Diff line change
1
+ package test .org .springdoc .api .app108 ;
2
+
3
+ public class ActionResult <T > {
4
+
5
+ protected T value ;
6
+ protected boolean success ;
7
+ protected String errorCode ;
8
+ protected String message ;
9
+ protected Object errorValue ;
10
+ protected String targetUrl ;
11
+
12
+ public T getValue () {
13
+ return value ;
14
+ }
15
+
16
+ public void setValue (T value ) {
17
+ this .value = value ;
18
+ }
19
+
20
+ public boolean isSuccess () {
21
+ return success ;
22
+ }
23
+
24
+ public void setSuccess (boolean success ) {
25
+ this .success = success ;
26
+ }
27
+
28
+ public String getErrorCode () {
29
+ return errorCode ;
30
+ }
31
+
32
+ public void setErrorCode (String errorCode ) {
33
+ this .errorCode = errorCode ;
34
+ }
35
+
36
+ public String getMessage () {
37
+ return message ;
38
+ }
39
+
40
+ public void setMessage (String message ) {
41
+ this .message = message ;
42
+ }
43
+
44
+ public Object getErrorValue () {
45
+ return errorValue ;
46
+ }
47
+
48
+ public void setErrorValue (Object errorValue ) {
49
+ this .errorValue = errorValue ;
50
+ }
51
+
52
+ public String getTargetUrl () {
53
+ return targetUrl ;
54
+ }
55
+
56
+ public void setTargetUrl (String targetUrl ) {
57
+ this .targetUrl = targetUrl ;
58
+ }
59
+ }
Original file line number Diff line number Diff line change
1
+ package test .org .springdoc .api .app108 ;
2
+
3
+ import org .springframework .web .bind .annotation .PostMapping ;
4
+ import org .springframework .web .bind .annotation .RestController ;
5
+
6
+ @ RestController
7
+ public class HelloController {
8
+
9
+ @ PostMapping
10
+ public ActionResult <Void > update (String toto ) {
11
+ return null ;
12
+ }
13
+ }
14
+
Original file line number Diff line number Diff line change
1
+ package test .org .springdoc .api .app108 ;
2
+
3
+ import test .org .springdoc .api .AbstractSpringDocTest ;
4
+
5
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
6
+
7
+ public class SpringDocApp108Test extends AbstractSpringDocTest {
8
+ @ SpringBootApplication
9
+ static class SpringDocTestApp {}
10
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "openapi" : " 3.0.1" ,
3
+ "info" : {
4
+ "title" : " OpenAPI definition" ,
5
+ "version" : " v0"
6
+ },
7
+ "servers" : [
8
+ {
9
+ "url" : " http://localhost" ,
10
+ "description" : " Generated server url"
11
+ }
12
+ ],
13
+ "paths" : {
14
+ "/" : {
15
+ "post" : {
16
+ "tags" : [
17
+ " hello-controller"
18
+ ],
19
+ "operationId" : " update" ,
20
+ "requestBody" : {
21
+ "content" : {
22
+ "application/json" : {
23
+ "schema" : {
24
+ "type" : " string"
25
+ }
26
+ }
27
+ }
28
+ },
29
+ "responses" : {
30
+ "200" : {
31
+ "description" : " default response" ,
32
+ "content" : {
33
+ "*/*" : {
34
+ "schema" : {
35
+ "$ref" : " #/components/schemas/ActionResultVoid"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "components" : {
45
+ "schemas" : {
46
+ "ActionResultVoid" : {
47
+ "type" : " object" ,
48
+ "properties" : {
49
+ "value" : {
50
+ "type" : " object"
51
+ },
52
+ "success" : {
53
+ "type" : " boolean"
54
+ },
55
+ "errorCode" : {
56
+ "type" : " string"
57
+ },
58
+ "message" : {
59
+ "type" : " string"
60
+ },
61
+ "errorValue" : {
62
+ "type" : " object"
63
+ },
64
+ "targetUrl" : {
65
+ "type" : " string"
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
You can’t perform that action at this time.
0 commit comments