Ask questionsSwagger for Server Sent Events
It would be nice if Swagger supported Server Sent Events. Which is a Uni-directional alternative for streaming content. This still would fall within REST to my knowledge (in particular due to last seen ID). A more concrete example can be seen at HTML5Rocks
semi-related : #55
Answer questions ragazzojp
As mentioned above, I think it's possible to do it if we generalize the support for non-JSON data. As simple types like integer and strings are the same when encoded in "text" instead of JSON, the only difference is visible in case of
array. We could add
format also to them, enabling things like:
/events: get: responses: 200: content: text/event-stream: schema: type: array # eventually also stream as new type, to mean unboundness, or a new parameter of array format: chunked # or whatever other keyword to mean chunks separated by empty lines # another use could be jsonlines, one line per JSON object, with no [ , ] items: type: object format: text # assuming this means "key: value", one per line, for each key # or we may introduce yaml !! 🥇 required: - id # not strictly required by SSE, but it's an example - event # not strictly required by SSE, but it's an example - data properties: # also possible to model with oneOf+discriminator id: type: integer description: my event id event: type: string description: my event type data: type: object # object in case we have a complex structure, otherwise string, integer, ..., as usual format: json # JSON is the default, but we may have different format as proposed above for the array required: - a - b properties: # as usual a: # ... b: # ... c: # ...
Note that this is not strictly limited to SSE. Enabling
object may have this and other applications. SSE protocol is modeled manually.