[REQ] Handle list of String special case in webclient generator
Created by: dlicois
Is your feature request related to a problem? Please describe.
When describing an operation that returns an array of string, the openapi-generator for java-webclient generates an api returning a Flux<String>
.
However Spring's Webclient handles serialization of JSON array of strings in a special way : spring-projects/spring-framework#22662
This means expecting a Flux<String>
when a server return an array of String is a mistake.
Please see sample Gradle project https://github.com/dlicois/webclient-liststring, it contains a test class (WebClientListStringTest.java) to better explain the behaviour.
The openapi.yaml
describes an operation returning an array of string, openapi-generator generates a DefaultApi.java
class returning a Flux<String>
.
When the webclient receive the answer ["one","two", "three"]
, it publishes a single String of value ["one","two", "three"]
.
I would have expected three Strings.
This makes the generated api unusable for this case, requiring to parse the response a second time to handle it.
Describe the solution you'd like
Recommended solution by Spring developers (see spring-projects/spring-framework#22662 and https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-codecs-jackson) is to use a Mono<List> for string arrays.
This would mean making a special case for operations described as arrays of string to generate a Mono<List> instead of Flux.