support for server sent events

Author: casualjimCreated Dec 3, 2015Updated Sep 9, 2026
Labelsenhancementfuture/maybeplease commentgenerator

Add support for server sent events

This includes a proposal to swagger-spec repo for an extension.

Server sent events are a specific mime type, currently in swagger 2.0 there is no support for different responses based on request criteria like content type.

In this proposal the idea is that the only possible response from that endpoint is a sse-eventstream

yaml
paths:
  /:
    get:
      produces: ["text/event-stream"]
      responses:
        default:
          description: example of defining events for sse 
          schema:
            type: object
            x-events:
              added:
                type: object
                properties:
                  message:
                    type: string
                  createdAt:
                    type: string
                    format: date-time
              updated:
                type: object
                  properties:
                    previous:
                      type: string
                    newValue:
                      type: string
                    updatedAt:
                      type: string
                      format: date-time

related: https://github.com/swagger-api/swagger-spec/issues/396