apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.37k stars 111 forks source link

Make request/response bodies an async sequence of bytes #9

Closed czechboy0 closed 12 months ago

czechboy0 commented 1 year ago

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.

FranzBusch commented 1 year ago

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.

czechboy0 commented 1 year ago

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 for text bodies. For more see #207.