[BUG] [kotlin-spring] in reactive mode Flow<String> is not the same as Mono<List<String>>
Description
The generator triggers an unfortunate behavior in Spring when the response of an operations is an array of plain strings. in that case the generator produces Flow<String> which spring will assume to be raw JSON and concatenate.
See this issue: https://github.com/spring-projects/spring-framework/issues/20807
openapi-generator version
5.2.0
OpenAPI declaration file content or url
openapi: 3.0.0
paths:
/itu/details:
get:
operationId: someOp
responses:
'200':
content:
application/json:
schema:
type: array
items:
type: string
Generation Details
The generator is kotlin-spring with delegatePattern = false. The generated operation method in the controller interface will have return type of Flow<String>, however according to the issue linked about this is not equivalent to List<String>.
So instead of:
fun someOp(): Flow<String>
it should generate something like
suspend fun someOp(): List<String>
as suggested by the issues. This is only necessary for a few specific "low-level" types like String and ByteArray.
Hi The same behavior happens with the Spring Java generator.
As @pschichtel says, maybe it would be nice to define the input parameters and return type as List<String> instead of Flux<String> when the type is a String (with other types, maintain the Flux)
Any advance?
+1
Any update regarding it? I was really surprised that my tests failed when switched reactive to true because of this serialisation.