How to omit methods from Swagger documentation on WebAPI using Swashbuckle

SteveWilkinson picture SteveWilkinson · Apr 17, 2015 · Viewed 82.5k times · Source

I have a C# ASP.NET WebAPI application with API documentation being automatically generated using Swashbuckle. I want to be able to omit certain methods from the documentation but I can't seem to work out how to tell Swagger not to include them in the Swagger UI output.

I sense it is something to do with adding a model or schema filter but it isn't obvious what to do and the documentation only seems to provide examples of how to modify the output for a method, not remove it completely from the output.

Thanks in advance.

Answer

mikesigs picture mikesigs · Jan 12, 2017

You can add the following attribute to Controllers and Actions to exclude them from the generated documentation: [ApiExplorerSettings(IgnoreApi = true)]