-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
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's ResponseEntity(inputStreamResource,...)
on the server side, and a okhttp's ResponseBody.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.