swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26k stars 8.86k forks source link

Support for Server-Sent-Events #4761

Open Firestorm87 opened 5 years ago

Firestorm87 commented 5 years ago

If the Backend provides an API with Content-Type "application/stream+json" or "text/event-stream" swagger-ui should use an EventSource instead of sending ajax http-requests.

code: var evtSource = new EventSource('http:server.domain.com/context_path)'); evtSource.onerror = function(e) { console.log(e.data); } evtSource.onmessage = function(event) { console.log(event.data); }

instead of logging the data it should be displayed in the response field.

For IE-Support maybe it is necessary to include an polyfill. e.g.: eventsource.js from https://github.com/Yaffle/EventSource/

oscarnalin commented 1 year ago

This is a great suggestion! Any chance it can be considered?