Skip to content

Commit 7303555

Browse files
committed
use publisher as response type wrapper instead of mono
1 parent be925d4 commit 7303555

File tree

5 files changed

+115
-3
lines changed

5 files changed

+115
-3
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/converters/ResponseSupportConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import static org.springdoc.core.converters.ConverterUtils.isResponseTypeToIgnore;
3535
import static org.springdoc.core.converters.ConverterUtils.isResponseTypeWrapper;
36+
import static org.springdoc.core.converters.ConverterUtils.isFluxTypeWrapper;
3637

3738
/**
3839
* The type Response support converter.
@@ -45,7 +46,7 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato
4546
JavaType javaType = Json.mapper().constructType(type.getType());
4647
if (javaType != null) {
4748
Class<?> cls = javaType.getRawClass();
48-
if (isResponseTypeWrapper(cls)) {
49+
if (isResponseTypeWrapper(cls) && !isFluxTypeWrapper(cls)) {
4950
JavaType innerType = javaType.getBindings().getBoundType(0);
5051
if (innerType == null)
5152
return new StringSchema();

springdoc-openapi-webflux-core/src/main/java/org/springdoc/webflux/core/converters/WebFluxSupportConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import io.swagger.v3.core.util.Json;
3131
import io.swagger.v3.oas.models.media.Schema;
3232
import io.swagger.v3.oas.models.media.StringSchema;
33+
import org.reactivestreams.Publisher;
3334
import reactor.core.publisher.Flux;
34-
import reactor.core.publisher.Mono;
3535

3636
import static org.springdoc.core.SpringDocUtils.getConfig;
3737
import static org.springdoc.core.converters.ConverterUtils.isFluxTypeWrapper;
@@ -45,7 +45,7 @@
4545
public class WebFluxSupportConverter implements ModelConverter {
4646

4747
static {
48-
getConfig().addResponseWrapperToIgnore(Mono.class)
48+
getConfig().addResponseWrapperToIgnore(Publisher.class)
4949
.addFluxWrapperToIgnore(Flux.class);
5050
}
5151

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
*
3+
* * Copyright 2019-2021 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.app152;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.springdoc.core.GroupedOpenApi;
23+
import org.springframework.context.annotation.Bean;
24+
import org.springframework.web.bind.annotation.GetMapping;
25+
import org.springframework.web.bind.annotation.RestController;
26+
import reactor.core.publisher.Mono;
27+
28+
@RestController
29+
public class HelloController {
30+
31+
@GetMapping("/persons")
32+
public Publisher<String> persons() {
33+
return Mono.just("OK");
34+
}
35+
36+
@Bean
37+
public GroupedOpenApi userOpenApi() {
38+
return GroupedOpenApi.builder()
39+
.group("users")
40+
.packagesToScan("test.org.springdoc.api.app152")
41+
.build();
42+
}
43+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
*
3+
* *
4+
* * * Copyright 2019-2021 the original author or authors.
5+
* * *
6+
* * * Licensed under the Apache License, Version 2.0 (the "License");
7+
* * * you may not use this file except in compliance with the License.
8+
* * * You may obtain a copy of the License at
9+
* * *
10+
* * * https://www.apache.org/licenses/LICENSE-2.0
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the License is distributed on an "AS IS" BASIS,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the License for the specific language governing permissions and
16+
* * * limitations under the License.
17+
* *
18+
*
19+
*/
20+
21+
package test.org.springdoc.api.app152;
22+
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.context.annotation.ComponentScan;
25+
import test.org.springdoc.api.AbstractSpringDocTest;
26+
27+
public class SpringDocApp152Test extends AbstractSpringDocTest {
28+
29+
@SpringBootApplication
30+
@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app152" })
31+
static class SpringDocTestApp {}
32+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"paths": {
14+
"/persons": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"operationId": "persons",
20+
"responses": {
21+
"200": {
22+
"description": "OK",
23+
"content": {
24+
"*/*": {
25+
"schema": {
26+
"type": "string"
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
},
35+
"components": {}
36+
}

0 commit comments

Comments
 (0)