Skip to content

How to allow a file download? #324

@hputus

Description

@hputus

Several 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions