What is the right 'type' parameter for SwaggerResponse attribute in case of FileStreamResult

Thomas Ansamma, ITP71, BUZ 21 Reputation points
2022-02-23T10:57:32.38+00:00

I am having a function which returns FileStreamResult.
When I set Type parameter as 'Stream' in SwaggerResponse I am getting exception while using the client package method.

Error Message :
"Could not deserialize the response body stream as ProjectName.Client.Stream.\n\nStatus: 200\nResponse: \n"

How to resolve this?

[HttpGet]
[SwaggerOperation(
OperationId = nameof(DownloadFileAsync), Produces = new[] { "application/yaml", "application/zip" }, Tags = new[] { "" })]
[SwaggerResponse(StatusCodes.Status200OK, nameof(StatusCodes.Status200OK), typeof(Stream))]
public async Task<IActionResult> DownloadFileAsync()
{
// some code here
return File(memoryStream, "application/zip", "fileName.zip");
}

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | ASP.NET | Other
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.