Skip to content

fix(kotlin-spring): fix Flow<String> and Flux<T> array return types for reactive generators#24101

Draft
Picazsoo wants to merge 6 commits into
OpenAPITools:masterfrom
Picazsoo:bugfix/flow-or-flux-of-string-to-mono-list
Draft

fix(kotlin-spring): fix Flow<String> and Flux<T> array return types for reactive generators#24101
Picazsoo wants to merge 6 commits into
OpenAPITools:masterfrom
Picazsoo:bugfix/flow-or-flux-of-string-to-mono-list

Conversation

@Picazsoo

@Picazsoo Picazsoo commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes reactive array return types in Kotlin Spring to avoid broken decoding and invalid signatures. Arrays of strings now return List<String>/Set<String> with suspend (not Flow<String>), and declarative Reactor interfaces return Mono<List<T>>/Mono<Set<T>> (not Flux<T>).

  • Bug Fixes

    • Coroutines (kotlin-spring): for array-of-string responses, generate suspend + List<String>/Set<String> to avoid Spring WebFlux StringDecoder swallowing JSON arrays (issue 22662).
    • Declarative Reactor (spring-declarative-http-interface): arrays now use Mono<{{returnContainer}}<T>> (e.g., Mono<List<T>>, Mono<Set<T>>), including Mono<ResponseEntity<...>> when enabled; removed reactor.core.publisher.Flux import.
    • Kotlin type handling: unwrap Set/MutableSet like List so returnType is the inner type and returnContainer is Set, fixing cases like Mono<set<kotlin.collections.Set<...>>>.
    • Added x-reactive-array-string-return vendor extension and updated templates to conditionally emit the new signatures.
    • Updated samples to use Mono<List<...>>/Mono<Set<...>> and drop Flux imports.
  • Migration

    • Coroutines server: replace Flow<String> with List<String> (or Set<String> for uniqueItems) and mark methods suspend.
    • Declarative Reactor: replace Flux<T> with Mono<List<T>>/Mono<Set<T>> (and Mono<ResponseEntity<...>> when used); update imports.

Written for commit a10b418. Summary will update on new commits.

Review in cubic

Picazsoo and others added 4 commits June 23, 2026 00:46
…tring> arrays

doDataTypeAssignment only unwrapped List/MutableList, leaving Set (uniqueItems) return types as the full 'kotlin.collections.Set<...>' with a raw 'set' container. This broke reactive array-of-string handling for Sets: the declarative reactor path emitted the non-compiling 'Mono<set<kotlin.collections.Set<kotlin.String>>>', and the coroutines path emitted a nonsensical non-suspend 'Flow<kotlin.collections.Set<kotlin.String>>'.

Unwrap Set/MutableSet like List so returnType becomes the inner type and returnContainer is 'Set'. This makes the x-reactive-array-string-return fix apply to Set<String> too, and also fixes the same latent bug in kotlin-server (ktor/javalin). Tightened the reactive tests to exercise the uniqueItems Set operation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo Picazsoo changed the title fix(kotlin-spring): fix Flow<String> and Flux<T> array return types f… fix(kotlin-spring): fix Flow<String> and Flux<T> array return types for reactive generators Jul 14, 2026
Picazsoo added 2 commits July 14, 2026 08:58
This reverts commit 6e851b4.
This reverts commit 7733960.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant