openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open VladimirSvoboda opened this issue 2 years ago • 2 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
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
  • #1309
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.

VladimirSvoboda avatar Oct 20 '23 16:10 VladimirSvoboda

Does anybody know a workaround to this issue?

baflo avatar Jan 08 '24 15:01 baflo

(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)

defaultbranch avatar May 13 '24 09:05 defaultbranch