mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 21:27:10 +00:00
[Java] [Spring] Fix reactive return type for list (#16884)
* Improve Add Async - Spring Cloud test By testing the generated code. This will be used to detect regressions. * Spring: Fix reactive return type for list Fix for #16883. When *reactive* is enabled and response entities is *disabled*, use `Flux<Item>` to stream the output instead of `Mono<Flux<Item>>` With Spring Reactive, the expected return type for an array of item is `Flux<Item>`. Without this patch, the generated code is `Mono<Flux<Item>>`. This is fixed by introducing specific handling for return types when reactive is enabled. In particular, "responseWrapper" is not used anymore in such situations. * Fix methodBody * Fix invalid test * Fix SSE * Fix methodBody when isArray and useResponseEntity * methodBody: Flux.empty() instead of s -> {}
This commit is contained in:
@@ -146,7 +146,7 @@ public interface PetApi {
|
||||
)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
|
||||
default Mono<Flux<Pet>> findPetsByStatus(
|
||||
default Flux<Pet> findPetsByStatus(
|
||||
@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status,
|
||||
@ApiIgnore final ServerWebExchange exchange
|
||||
) {
|
||||
@@ -189,7 +189,7 @@ public interface PetApi {
|
||||
)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
|
||||
default Mono<Flux<Pet>> findPetsByTags(
|
||||
default Flux<Pet> findPetsByTags(
|
||||
@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) Set<String> tags,
|
||||
@ApiIgnore final ServerWebExchange exchange
|
||||
) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public interface PetApiDelegate {
|
||||
* or Invalid status value (status code 400)
|
||||
* @see PetApi#findPetsByStatus
|
||||
*/
|
||||
default Mono<Flux<Pet>> findPetsByStatus(List<String> status,
|
||||
default Flux<Pet> findPetsByStatus(List<String> status,
|
||||
ServerWebExchange exchange) {
|
||||
Mono<Void> result = Mono.empty();
|
||||
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
|
||||
@@ -92,7 +92,7 @@ public interface PetApiDelegate {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.then(Mono.empty());
|
||||
return result.thenMany(Flux.empty());
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public interface PetApiDelegate {
|
||||
* @see PetApi#findPetsByTags
|
||||
*/
|
||||
@Deprecated
|
||||
default Mono<Flux<Pet>> findPetsByTags(Set<String> tags,
|
||||
default Flux<Pet> findPetsByTags(Set<String> tags,
|
||||
ServerWebExchange exchange) {
|
||||
Mono<Void> result = Mono.empty();
|
||||
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
|
||||
@@ -123,7 +123,7 @@ public interface PetApiDelegate {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.then(Mono.empty());
|
||||
return result.thenMany(Flux.empty());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user