Create a gist now

Instantly share code, notes, and snippets.

@justinyoo /Produces.cs Secret
Created Jul 30, 2017

What would you like to do?
Swashbuckle Pro Tips for ASP.NET Web API #1
public class Produces : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
var attribute = apiDescription.GetControllerAndActionAttributes<SwaggerProducesAttribute>().SingleOrDefault();
if (attribute == null)
{
return;
}
operation.produces.Clear();
operation.produces = attribute.ContentTypes.ToList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment