pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

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

Open carusyte opened 11 months ago

carusyte commented 11 months ago

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

pgjones commented 7 months ago

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

pamelafox commented 6 months ago

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.