Native support for Server-Sent Events and Streaming API endpoints

Open
#219 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java, spring
Domain
api, documentation

Research direction

Start by examining the SseEmitter and ResponseBodyEmitter return types and the proposed Spring Web Reactive types Flux and Observable. Define what generated documentation should cover for text/event-stream responses, including curl examples, non-closing connections, and possible JavaScript usage.

Written by the indexing model from the issue text.

Description

type: enhancement

Maybe Spring REST Docs could support natively Server-Sent Events endpoints, as supported in Spring Framework 4.2+ thanks to SseEmitter type, and global Streaming API support based on ResponseBodyEmitter type.

I am not sure yet about what that support would be, but for example Spring REST Docs could recognize SseEmitter return types, and generate a snippet with a curl command with text/event-streammedia type, handle the fact that some SSE endpoints never closes the connection (handle a timeout but not as an error?), and eventually provide Javascript code that would help people to use that endpoint in their application.

This issue is also intended to prepare support for Spring Web Reactive, which will provide first class support for streaming API via handler methods returning types like Flux<Foo> or Observable<Foo>. And unlike SseEmitter and ResponseBodyEmitter, these types will carry more type information within their Generic type.

Dominant language
Java
Stars
1.2k
Forks
731
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spring-projects/spring-restdocs

All issues in spring-projects/spring-restdocs

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.