From 4e2ce0e46654833a0dff5bd25ad45706bda17522 Mon Sep 17 00:00:00 2001 From: kdelay Date: Thu, 17 Sep 2026 19:23:00 +0900 Subject: [PATCH] fix: unwrap a WebAsyncTask return type --- .../configuration/SpringDocConfiguration.java | 4 ++- .../api/v30/app273/HelloController.java | 33 +++++++++++++++++++ .../api/v30/app273/SpringDocApp273Test.java | 31 +++++++++++++++++ .../api/v31/app273/HelloController.java | 33 +++++++++++++++++++ .../api/v31/app273/SpringDocApp273Test.java | 31 +++++++++++++++++ .../test/resources/results/3.0.1/app273.json | 32 ++++++++++++++++++ .../test/resources/results/3.1.0/app273.json | 32 ++++++++++++++++++ 7 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/HelloController.java create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/SpringDocApp273Test.java create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/HelloController.java create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/SpringDocApp273Test.java create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app273.json create mode 100644 springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app273.json diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java index 17c977e52..f728c4470 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java @@ -132,6 +132,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.context.request.async.DeferredResult; +import org.springframework.web.context.request.async.WebAsyncTask; import static org.springdoc.core.utils.Constants.GLOBAL_OPEN_API_CUSTOMIZER; import static org.springdoc.core.utils.Constants.SPRINGDOC_DEPRECATING_CONVERTER_ENABLED; @@ -163,7 +164,8 @@ public class SpringDocConfiguration { getConfig().replaceWithSchema(ObjectNode.class, new ObjectSchema()) .replaceWithClass(Charset.class, String.class) .addResponseWrapperToIgnore(DeferredResult.class) - .addResponseWrapperToIgnore(Future.class); + .addResponseWrapperToIgnore(Future.class) + .addResponseWrapperToIgnore(WebAsyncTask.class); } /** diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/HelloController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/HelloController.java new file mode 100644 index 000000000..896bead5f --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/HelloController.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2026 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test.org.springdoc.api.v30.app273; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.async.WebAsyncTask; + +/** + * A controller that returns an asynchronous result with a timeout. + */ +@RestController +public class HelloController { + + @GetMapping("/hello") + public WebAsyncTask hello() { + return new WebAsyncTask<>(1000L, () -> "hello"); + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/SpringDocApp273Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/SpringDocApp273Test.java new file mode 100644 index 000000000..1f06d550b --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app273/SpringDocApp273Test.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2026 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test.org.springdoc.api.v30.app273; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * A WebAsyncTask return type is a response wrapper, not a schema. + */ +public class SpringDocApp273Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/HelloController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/HelloController.java new file mode 100644 index 000000000..438ceb4a1 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/HelloController.java @@ -0,0 +1,33 @@ +/* + * Copyright 2019-2026 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test.org.springdoc.api.v31.app273; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.async.WebAsyncTask; + +/** + * A controller that returns an asynchronous result with a timeout. + */ +@RestController +public class HelloController { + + @GetMapping("/hello") + public WebAsyncTask hello() { + return new WebAsyncTask<>(1000L, () -> "hello"); + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/SpringDocApp273Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/SpringDocApp273Test.java new file mode 100644 index 000000000..4bd83899a --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app273/SpringDocApp273Test.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2026 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package test.org.springdoc.api.v31.app273; + +import test.org.springdoc.api.v31.AbstractSpringDocV31Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * A WebAsyncTask return type is a response wrapper, not a schema. + */ +public class SpringDocApp273Test extends AbstractSpringDocV31Test { + + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app273.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app273.json new file mode 100644 index 000000000..1f1bf7389 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app273.json @@ -0,0 +1,32 @@ +{ + "openapi" : "3.0.1", + "info" : { + "title" : "OpenAPI definition", + "version" : "v0" + }, + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/hello" : { + "get" : { + "tags" : [ "hello-controller" ], + "operationId" : "hello", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "*/*" : { + "schema" : { + "type" : "string" + } + } + } + } + } + } + } + }, + "components" : { } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app273.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app273.json new file mode 100644 index 000000000..3b9eec0c3 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app273.json @@ -0,0 +1,32 @@ +{ + "openapi" : "3.1.0", + "info" : { + "title" : "OpenAPI definition", + "version" : "v0" + }, + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/hello" : { + "get" : { + "tags" : [ "hello-controller" ], + "operationId" : "hello", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "*/*" : { + "schema" : { + "type" : "string" + } + } + } + } + } + } + } + }, + "components" : { } +}