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.
The NSwag project provides tools to generate OpenAPI specifications from existing ASP.NET Web API controllers and client code from these OpenAPI specifications. The project combines the functionality of Swashbuckle (OpenAPI/Swagger generation) and AutoRest (client generation) in one toolchain.
NSwag is a Swagger 2.0 API (OpenAPI) toolchain for . NET, Web API, TypeScript (jQuery, AngularJS, Angular 2+, Aurelia, KnockoutJS, and more) and other platforms, written in C#. The Swagger specification uses JSON and JSON Schema to describe a RESTful web API.
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...
Use
[OpenApiIgnore]
(since [SwaggerIgnore]
has been deprecated)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With