Skip to content

Commit f9d0318

Browse files
author
bnasslahsen
committed
Support for DeferredResult. Fixes #804
1 parent a2e0469 commit f9d0318

File tree

6 files changed

+165
-1
lines changed

6 files changed

+165
-1
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.springframework.web.bind.annotation.ResponseStatus;
6565
import org.springframework.web.bind.annotation.RestControllerAdvice;
6666
import org.springframework.web.context.request.WebRequest;
67+
import org.springframework.web.context.request.async.DeferredResult;
6768

6869
import static org.springdoc.core.Constants.SPRINGDOC_DEPRECATING_CONVERTER_ENABLED;
6970
import static org.springdoc.core.Constants.SPRINGDOC_ENABLED;
@@ -84,7 +85,8 @@ public class SpringDocConfiguration {
8485
private static final String BINDRESULT_CLASS = "org.springframework.boot.context.properties.bind.BindResult";
8586

8687
static {
87-
getConfig().replaceWithSchema(ObjectNode.class, new ObjectSchema());
88+
getConfig().replaceWithSchema(ObjectNode.class, new ObjectSchema())
89+
.addResponseWrapperToIgnore(DeferredResult.class);
8890
}
8991

9092
/**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test.org.springdoc.api.app129;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class ActualReturnedEntity {
6+
7+
@JsonProperty
8+
String result;
9+
10+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.app129;
20+
21+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
22+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
23+
24+
import org.springframework.web.bind.annotation.GetMapping;
25+
import org.springframework.web.bind.annotation.RequestBody;
26+
import org.springframework.web.bind.annotation.RequestMapping;
27+
import org.springframework.web.bind.annotation.RestController;
28+
import org.springframework.web.context.request.async.DeferredResult;
29+
30+
@RestController
31+
@RequestMapping("/api")
32+
public class HelloController {
33+
34+
@GetMapping("/test")
35+
@ApiResponses({@ApiResponse(responseCode = "200")})
36+
public DeferredResult<OperationResponse<ActualReturnedEntity>> update(
37+
@RequestBody ActualReturnedEntity entity) throws Exception {
38+
return null;
39+
}
40+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test.org.springdoc.api.app129;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class OperationResponse<T> {
6+
7+
@JsonProperty
8+
String operationResult;
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
package test.org.springdoc.api.app129;
24+
25+
import test.org.springdoc.api.AbstractSpringDocTest;
26+
27+
import org.springframework.boot.autoconfigure.SpringBootApplication;
28+
29+
30+
/**
31+
* Tests Spring meta-annotations as method parameters
32+
*/
33+
public class SpringDocApp129Test extends AbstractSpringDocTest {
34+
35+
@SpringBootApplication
36+
static class SpringDocTestApp {}
37+
38+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
"/api/test": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"operationId": "update",
20+
"parameters": [
21+
{
22+
"name": "entity",
23+
"in": "query",
24+
"required": true,
25+
"schema": {
26+
"$ref": "#/components/schemas/ActualReturnedEntity"
27+
}
28+
}
29+
],
30+
"responses": {
31+
"200": {
32+
"description": "OK",
33+
"content": {
34+
"*/*": {
35+
"schema": {
36+
"$ref": "#/components/schemas/OperationResponseActualReturnedEntity"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
},
45+
"components": {
46+
"schemas": {
47+
"ActualReturnedEntity": {
48+
"type": "object",
49+
"properties": {
50+
"result": {
51+
"type": "string"
52+
}
53+
}
54+
},
55+
"OperationResponseActualReturnedEntity": {
56+
"type": "object",
57+
"properties": {
58+
"operationResult": {
59+
"type": "string"
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)