quart-schema icon indicating copy to clipboard operation
quart-schema copied to clipboard

How can we add "text/event-stream" to the "Accept/Content-Type" headers?

Open carusyte opened this issue 1 year ago • 2 comments

This is needed to support Server Sent Events or Streaming not only in validation step but for the generated SwaggerUI API docs as well.

carusyte avatar Oct 13 '23 02:10 carusyte

Can you share an example of what the OpenAPI schema looks like for a SSE route?

pgjones avatar Jan 30 '24 19:01 pgjones

When I last looked into this, it was an open discussion as to how OpenAPI should document SSE routes and streaming routes generally.

I am personally trying to add validation (or at least documentation) for a route that responds with a stream with a mime-type of "application/json-lines", a "transfer-encoding": "chunked" header, and newline-delimited JSON. I attempted to use validate_response, but wasn't sure what to put in there as the data type.

Here's how the streaming response gets rendered, with no validation:

Screenshot 2024-02-13 at 4 36 14 PM

I'd love to document the response format more formally if possible.

pamelafox avatar Feb 14 '24 00:02 pamelafox