paperclip-rs / paperclip

WIP OpenAPI tooling for Rust.
Apache License 2.0
890 stars 117 forks source link

ResponseStream::to_writer doesn't handle written amount #490

Closed sciguy16 closed 1 year ago

sciguy16 commented 1 year ago

The ResponseStream::to_writer function does not check the return value from writer.write(chunk.as_ref()).await?. This could result in data getting lost if a chunk is only partially written to the recieving stream and was picked up by the clippy::unused_io_amount lint.

https://github.com/paperclip-rs/paperclip/blob/db3b920d6b8738bf5d1aa1d4701e3e74d05afd46/src/build/util_mod.hbs#L30-L40

The best solution is probably to replace write with write_all to ensure that the full buffer gets written. I'm happy to make a PR for that change.

tiagolobocastro commented 1 year ago

I've never delved into this part of the code so happy to receive a a PR for it if you're willing, thank you!