Open gpor0 opened 4 years ago
Any news?
Hello there :wave:
I require this feature too, and I am willing to contribute a Pull Request. First of all, I'd like to make sure that the PR gets eventually merged in the end, so some feedback from a maintainer (@cachescrubber ?) would be awesome.
SseEmitter
only for the Spring generator or is it required to provide similar implementations for all available code generators?apiController.mustache
needs to be adjusted to conditionally return SseEmitter
instead of ResponseEntity
SseEmitter
instead of ResponseEntity
in case
content
property has set text-eventstream
as type andtype
is array
andformat
is event-stream
?
/notifications:
get:
description: Retrieve notifications
operationId: getNotifications
responses:
200:
description: Currently active operation
content:
text/event-stream:
schema:
type: array
format: event-stream
items:
$ref: '#/components/schemas/Notification'
SpringCodegen.java
would need to be adjusted to fill in the needed import
statements and set the boolean
switch to make the decision in the template which response type to useAny advances or alternatives? I would need this feature too.
+1!
Hi y'all, I'm trying to consume from a server sent event stream using a java sdk generated by the openapi-generator, and I'm having trouble with this..
Using a generated python sdk, I was able to use preload_content = False so that I could process the events while the connection is open, but in the java sdk generated, I haven't determined a way to do that.
@danipenaperez, @stefan-niedermann, @jorgerod, @gpor0, Any luck on this, or do you have any tips? I might fork and try to add it myself if it is not possible as is.
I did not make any progress and I see this topic totally blocked.
Recent AI era requires SSE than before. I hope SSE is supported.
@ https://github.com/OpenAPITools/openapi-generator/issues/6123#issuecomment-1050889080:
The return value of the generated method should be
SseEmitter
instead ofResponseEntity
in case
- the
content
property has settext-eventstream
as type and- the
type
isarray
and- the
format
isevent-stream
?/notifications: get: description: Retrieve notifications operationId: getNotifications responses: 200: description: Currently active operation content: text/event-stream: schema: type: array format: event-stream items: $ref: '#/components/schemas/Notification'
This is exactly the style we would like to use in. We are running a Spring application, so having it purely for a SpringCodegen would work fine for us.
Another contribution which referencing this one has already added support for reactive Spring applications, but we have an application which is mostly non-reactive (with ResponseEntities), and only has a couple of server-sent event endpoints we implement with SseEmitter
s.
Am I correct in understanding that as of now Openapi-generator only supports SSE for Spring?
Yes, the https://github.com/OpenAPITools/openapi-generator/pull/16543 introduced it for spring
Is your feature request related to a problem? Please describe.
It is currently impossible to generate stubs and support server sent events in some languages (like Java JAX-RS spec) since there is missing code for SSE (text/event-stream).
Describe the solution you'd like
Introduce isEventStream property in Operation class (and set to true if produces has text/event-stream value) and add missing information to templates (
@Context SseEventSink
for Java) etc...Describe alternatives you've considered
/
Additional context
/