Skip to content

Support for Streams in Responses #1576

@emmanuelproulx

Description

@emmanuelproulx

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.

Metadata

Metadata

Assignees

Labels

httpSupporting HTTP features and interactionsmedia and encodingIssues regarding media type support and how to encode data (outside of query/path params)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions