Smallrye OpenAPI generation for SSE with Multi return type generates array type
Describe the bug
When generating the OpenAPI for a REST endpoint producing SSE that returns a Multi, the generated type is wrong.
Code:
@GET
@Path("/multi")
@Produces(MediaType.SERVER_SENT_EVENTS)
fun helloMulti(): Multi<String> = Multi.createFrom().items("1", "2", "3")
This generates the following OpenAPI Spec
openapi: 3.1.0
paths:
/hello/multi:
get:
responses:
"200":
description: OK
content:
text/event-stream:
schema:
type: array
items:
type: string
summary: Hello Multi
tags:
- Greeting Resource
Here, the schema of the text/event-stream is of type array with items of type string. However, we do not return arrays of strings but only strings in a stream.
If we generate the same OpenAPI Spec with the method returning a Kotlin Flow, the generated result is correct.
openapi: 3.1.0
paths:
/hello/flow:
get:
responses:
"200":
description: OK
content:
text/event-stream:
schema:
type: string
summary: Hello Flow
tags:
- Greeting Resource
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
Reproducer: 2025-11-19_Multi-OpenAPI-Bug.zip
- Unzip the reproducer
- run
./gradlew assemble - Check out the OpenAPI Spec in the
openapidirectory.
Output of uname -a or ver
No response
Output of java -version
No response
Quarkus version or git rev
Quarkus 3.29.3
Build tool (ie. output of mvnw --version or gradlew --version)
gradlew
Additional information
No response
/cc @EricWittmann (openapi), @Ladicek (smallrye), @MikeEdgar (openapi), @geoand (kotlin), @jmartisk (smallrye), @phillip-kruger (openapi,smallrye), @radcortez (smallrye)
@andreas-eberle have you tried using an annotation on the REST method to provide the schema you're looking for? Something like this:
@APIResponseSchema(String.class)
Hi @MikeEdgar,
yes, using the annotation fixes it. But shouldn't Quarkus detect it correctly automatically? Like it does with the Flow.
That is probably reasonable, but I wonder does it universally apply for any Multi<T> with a content-type of text/event-stream ?
I'm not sure what exactly you mean. Can you explain a bit more? Then I could test it.
@andreas-eberle I just am questioning whether a Multi always (or more often than not) should result in the response schema you're expecting rather than an array. I'm unsure myself.
I think at least in the case of an SSE response format, It should not be an array. If it makes sense to use Multi for non-SSE, I don't know.