How to allow a file download?
See original GitHub issueSeveral of my API methods result in a file download. How can I get Swashbuckle to download a file through the UI for these methods?
I’ve added an IOperationFilter with the following Apply method to add a “produces” attribute to certain methods:
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
if (apiDescription.ID == "GETapi/Templates/{id}")
{
operation.produces.Add("application/octet-stream");
}
}
But when I execute this method through the Swashbuckle UI it displays the file contents in the “Response Body” textarea. Is there a way of getting a file to actually download?
Thanks
Issue Analytics
- State:
- Created 8 years ago
- Comments:22 (3 by maintainers)
Top Results From Across the Web
Download a file - Computer - Google Chrome Help
Download a file ; At the top right, click More More · Settings ; Click Privacy and security · Site Settings ; Click...
Read more >Automatic file download notifications in Windows
Tip: Don't want notifications for automatic file downloads? Go to your notifications settings and then, under Get notifications from these senders, turn off ......
Read more >How to Block or Unblock Downloads in Google Chrome
Open Google Chrome on your mobile device. · Tap the three-dot icon. · Choose Privacy and Security. · Tap on Safe Browsing. ·...
Read more >Cannot download a file from the Internet? Do this!
In Security Settings, scroll down to Downloads. Set File download to Enable. Scroll down a bit more and you will see Miscellaneous. Here...
Read more >How to enable Automatic file download in Windows 10 ...
1 Answer 1 ... When this button is greyed out, it means you have not blocked any apps from requesting automatic file downloads....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Weird, we are having the same problem. We have the latest version of SB 2.4.0. Why is this closed?
We have the following function:
Which produces the following Swagger Spec:
This is not correct, so when I generate a client with AutoRest or NSwag, it tries to serialize the data as JSON.
I monkey patched it with this operation filter and it works fine:
@centur - you can wire up an IOperationFilter (see readme for details). It would look something like this …
I’ve used this to create a valid spec, but it seems the UI still doesn’t support the downloads yet …