I have the following route mapped in a Mininal API application:
app.MapGet("api/test", async Task<Results<PushStreamHttpResult, NotFound>> (bool fail) => {
if (fail) return TypedResults.NotFound();
return TypedResults.Stream(stream => WriteToStream(stream), "text/plain");
}).WithSummary("Test Streaming results");
async Task WriteToStream(Stream stream) {
// do the writing... not needed for sample code
}
I didn't find a way to generate the proper documentation for this TypedResults type in swagger/OpenAPI UI and schemas. I can do this for other result types:
app.MapGet("api/thisworks", async Task<
Results<
Ok<ApiResult>,
BadRequest<ApiResult>,
NotFound<ApiResult>>> () => { ... }
Which produces proper documentation for the many return types like this for example:
Is there a way to automatically achieve the same with TypedResults.Stream / PushStreamHttpResult ?


From the swagger docs:
PushStreamHttpResultis file result too and it seems that the same rules are applied to it also so you can use theProducescall, for example:If all
PushStreamHttpResultare plain texts then you can try to automate it with operation filter:And add it to filters: