Server Sent Events and Streaming APIs
Use the x-fern-streaming
extension to model streaming endpoints
The x-fern-streaming
extension allows you to represent endpoints that are streaming.
JSON streaming
If your API returns a series of JSON
chunks as seen below
then simply add the x-fern-streaming: true
to your OpenAPI operation.
openapi.yml
Server sent events
If your API returns server-sent-events, with the data
and event
keys as seen below
then make sure to include format: sse
.
openapi.yml
Stream
parameter
It has become common practice for endpoints to have a stream
parameter that
controls whether the response is streamed or not. Fern supports this pattern in a first
class way.
Simply specify the stream-condition
as well as the ordinary response and the streaming response:
openapi.yml