-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Support for Streams in Responses #1576
Copy link
Copy link
Closed
Labels
httpSupporting HTTP features and interactionsSupporting HTTP features and interactionsmedia and encodingIssues regarding media type support and how to encode data (outside of query/path params)Issues regarding media type support and how to encode data (outside of query/path params)
Milestone
Description
Metadata
Metadata
Assignees
Labels
httpSupporting HTTP features and interactionsSupporting HTTP features and interactionsmedia and encodingIssues regarding media type support and how to encode data (outside of query/path params)Issues regarding media type support and how to encode data (outside of query/path params)
Type
Fields
Give feedbackNo fields configured for issues without a type.
APIs that download binary data currently must be done by
type: string, format: binary. This translates to byte arrays (in Java for example, anyway that's what swagger-ui and swagger-codegen do). But this consumes large amounts of memory if the data is very big, and easily gives out-of-memory errors.Typically huge blocks of data are sent via streams instead of byte arrays in most remote APIs. This allows for loading only a block of data at a time in memory.
The workaround used to be the '
file' format but this was removed in version 3.What I propose is a new
type: stream(format: binary) which would allow this. As an example, this could map to Spring'sResponseEntity(inputStreamResource,...)on the server side, and a okhttp'sResponseBody.byteStream()on the client side. Lots of HTTP client & server frameworks support streams in API implementations so I'm surprised it doesn't already exist.