OpenAPITools / OpenAPITools/openapi-generator
[BUG] [kotlin-spring] in reactive mode Flow<String> is not the same as Mono<List<String>>
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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 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.
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the kotlin-spring generator and the provided OpenAPI declaration, using reactive mode with delegatePattern=false. Inspect how the generated controller interface chooses Flow for an array of strings and compare it with Spring issue 20807. Done means the generated signature uses a suitable suspend function and List for the affected low-level types, with coverage for the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi, spring
- Domain
- api, backend, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100