OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.56k stars 6.28k forks source link

[BUG] [Spring] Mono<Flux<Item> is generated instead of Flux<Item> when reactive is enabled #16883

Open VladimirSvoboda opened 8 months ago

VladimirSvoboda commented 8 months ago

Bug Report Checklist

Description

With the Spring generator, with reactive enabled and responseEntity disabled. The generated server code for operations returning array of elements must be Flux<Item> and not Mono<Flux<Item>>

openapi-generator version

7.0.1

OpenAPI declaration file content or url

modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml

Generation Details

Sample config file: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml

Steps to reproduce

Generate and check the return type of the method findPetsByStatus

Related issues/PRs
Suggest a fix

Currently, the code assumes that Mono is the response wrapper to always use when reactive is enabled. This is false when data are arrays.

baflo commented 5 months ago

Does anybody know a workaround to this issue?

defaultbranch commented 1 month ago

(just a comment: this issue also touches the older, still unresolved bug #10250: because Spring does the serialization for Flux<String> in plaintext instead of JSON (explained in https://github.com/spring-projects/spring-framework/issues/20807), people wanting the response to be in JSON wish for Mono<List<String>> as response data type instead) (however, this is another issue, and I understand if it will be handled separately)