How to download a file in Swagger UI instead of displaying blob of text

If I enter the URL (http://localhost:13225/hellozip) in a browser the file is download in the usual way.

However if I navigate to the swagger ui and “Try it now” the response is a blob of text instead of downloading the file. Can you point out what I’m doing incorrectly. Thanks

[Route("/hellozip")]
public class HelloZip { }

public object Get(HelloZip request)
{
    string tempPath = Path.GetTempPath();
    string filePath = Path.Combine(tempPath, "HelloTest.zip");
    base.Response.ContentType = "application/zip";

    using (MemoryStream memoryStream = new MemoryStream())
    {
        using (var zipArchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
        {
            ZipArchiveEntry zipArchiveEntry = zipArchive.CreateEntry("Foo.txt");
            using (Stream stream = zipArchiveEntry.Open())
            {
                using (StreamWriter streamWriter = new StreamWriter(stream))
                {
                    streamWriter.Write("Bar!");
                }
            }
        }

        using (var fileStream = new FileStream(filePath, FileMode.Create))
        {
            memoryStream.Seek(0, SeekOrigin.Begin);
            memoryStream.CopyTo(fileStream);
        }
    }

    return new HttpResult(new FileInfo(filePath), true);
}

Swagger is likely going to assume it’s the wrong type since it assumes APIs return JSON by default.

Can you post the raw HTTP Request and Respone Headers for the request Swagger makes, using Chrome WebInspector or Fiddler?

Swagger UI has an issue with attachments: recent versions of Swagger UI (which are used in Servicestack.Api.OpenApi plugin) corrupt the attachment file which is returned by the service and older vesions of Swagger UI (which is used in ServiceStack.Swagger plugin) look like not returning the attachment and just returning content of the file.

We should wait while Swagger UI will fix that issue and after this Swagger UI can be updated in plugins and can be used for downloading attachments.