swift-openapi-generator icon indicating copy to clipboard operation
swift-openapi-generator copied to clipboard

Make request/response bodies an async sequence of bytes

Open czechboy0 opened this issue 2 years ago • 1 comments

For simplicity, initially the type holding the raw request and response body data is Foundation.Data, but that prevents use cases where large amounts of data need to be sent/received if the memory limit of the process is low.

What should be possible: a uploading/downloading large (multi-GB) files without buffering them into memory on either client/server ends.

czechboy0 avatar May 25 '23 08:05 czechboy0

This is an important topic to cover and something that we are currently discussing in the broader ecosystem. The SSWG is currently gathering requirements for a general purpose HTTP server. One of the key functionalities of this new type is support for full bidirectional streaming. I think we should follow the API design of the general purpose HTTP server here in OpenAPI.

FranzBusch avatar Jun 09 '23 08:06 FranzBusch

We might need to provide an async body not just for raw byte content types, but also for text/*, as text/event-stream would need that to work.

Either we'll exclude text/event-stream from being returned as String, or we'll need to provide AsyncSequence<String> for text bodies. For more see #207.

czechboy0 avatar Aug 18 '23 07:08 czechboy0