juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2k stars 160 forks source link

Return binary in API #959

Open wangjia184 opened 2 weeks ago

wangjia184 commented 2 weeks ago

Hi

I want to implement an API to return an image as raw binary. Content-type should be image/png . So when this API is opened in web browser, the image is presented.

After reading the example https://github.com/juhaku/utoipa/blob/d020f92a0446adc7e99999aa9e1be63e95728fbb/examples/rocket-todo/src/main.rs, I still don't find a way.

The IntoResponses and ToResponse traits seems does not allow to return raw binary body?