We have a couple of ApiController
implementations and we do not want most operations to be included in the metadata of ApiExplorer.
By default, if you do not add [ApiExplorerSettings(IgnoreApi = true)]
to your operation, it will be added so this means the default is false.
This probably due to IgnoreApi
being a boolean and defaulting to false
but how can I change this default to true
without having to override ApiExplorerSettings
?
This is a basic WebApi implementation without using MVC components.
I tried looking around for simple config based solutions or examples of ApiExplorerSettings
usage but none have really worked out for me.
The closest to what I want is: DotNetCore - is ApiExplorer supported, and how to use it?; however, it focuses on MVC.
// For example
[RoutePrefix("api/test")]
public class TestController : ApiController
{
[HttpGet]
[Route("helloworld")]
[ApiExplorerSettings(IgnoreApi = false)]
public string HelloWorld() {
return "Hello world!";
}
[HttpGet]
[Route("goodbyeworld")]
[ApiExplorerSettings(IgnoreApi = true)]
public string HelloWorld() {
return "Goodbye world!";
}
[HttpGet]
[Route("hiworld")]
[ApiExplorerSettings(IgnoreApi = true)]
public string HelloWorld() {
return "Hi world!";
}
[HttpGet]
[Route("seeyaworld")]
[ApiExplorerSettings(IgnoreApi = true)]
public string HelloWorld() {
return "See ya world!";
}
}
I want to be able to just use ApiExplorerSettings
on operations which I want to use instead of marking the ones I do not want to use.