1

I have a controller which I declare, at class level, to not show up in the autogenerated API Help Page, like so:

[Authorize, ApiExplorerSettings(IgnoreApi = true)]
public class MyController : ApiController {
    public HttpResponseMessage method1() {/*...*/}
    public HttpResponseMessage method2() {/*...*/}
    public HttpResponseMessage method3() {/*...*/}
    /*...*/
}

Now say I want to override the ApiExplorerSettings annotation just for method2 in order to add it to the docs. I obviously tried:

[Authorize, ApiExplorerSettings(IgnoreApi = true)]
public class MyController : ApiController {
    public HttpResponseMessage method1() {/*...*/}
    [ApiExplorerSettings(IgnoreApi = false)]
    public HttpResponseMessage method2() {/*...*/}
    public HttpResponseMessage method3() {/*...*/}
    /*...*/
}

but to no avail. Any insight as to how I could achieve this behavior?
Cheers.

Andrea Aloi
  • 971
  • 1
  • 17
  • 37

1 Answers1

0

If you are using Swashbuckle to generate your API help page, you can configure SwaggerGen with a DocumentFilter. The filter allows you to programmatically modify the SwaggerDocument, (i.e. add or remove some methods) before it is made available to SwaggerUI.

Some more details here

Vincent
  • 289
  • 1
  • 3
  • 9