Is it possible to have NSwag ignore a controller?

James B. Nall picture James B. Nall · Apr 18, 2017 · Viewed 7.7k times · Source

I used NSwag to generate a client for a single controller; I needed it as its own separate client. I would like for it to be ignored when the Swagger specification is generated in the future.

I tried adding this attribute at the top of the controller but it is still being noted in the specification: [ApiExplorerSettings(IgnoreApi = true)]

My controller is implementing the standard Microsoft.AspNetCore.Mvc.Controller class.

Answer

Rico Suter picture Rico Suter · Apr 18, 2017

I think in the latest version,

[ApiExplorerSettings(IgnoreApi = true)]

is supported.

Otherwise you can add the SwaggerIgnoreAttribute OR OpenApiIgnoreAttribute attribute

[SwaggerIgnore]
[OpenApiIgnore]

Or manually select the controllers in NSwagStudio or in the middleware...