-
-
Notifications
You must be signed in to change notification settings - Fork 522
Description
What is the problem this feature would solve?
I would like to specify how my event-stream response is encoded when creating my HttpApiEndpoint, and for that to generate the appropriate OpenAPI 3.2 JsonSchema:
{
"text/event-stream": {
"schema": {"type": "string"},
"itemSchema": {"$ref": "#/components/schemas/MyEventSchema"}
}
}( see https://www.openapis.org/blog/2025/09/23/announcing-openapi-v3-2#sequential-and-streaming-data )
And I guess also make it so the generated HttpApiClient automatically creates an Effect Stream with the decoded events inside, and the server implementation won't need manual encoding of the events to text.
What is the feature you are proposing to solve the problem?
Something like this:
HttpApiSchema.withEncoding(MyEventSchema, {
kind: 'EventStream', //<--- currently not supported
})Or this, if it makes more sense:
HttpApiSchema.withEncoding(S.String, {
kind: 'Text',
contentType: 'text/event-stream',
itemSchema: MyEventSchema, //<--- currently not supported
})What alternatives have you considered?
For now the best option I found is using an OpenApi.Transform annotation and manually injecting all my event stream types into the components, and manually setting an itemSchema property on my my text/event-stream endpoints after defining them like this:
HttpApiSchema.withEncoding(S.String, {
kind: 'Text',
contentType: 'text/event-stream',
})And for the generated client, manually decoding the EventSource to a Stream.
And for the server implementation, manually encoding the Stream items to Text Buffers.
Related issues
- HTTP Server/Client: add SSE ( Server-Send-Event) #3527 (possible duplicate, albeit very sparsely described)