在方法上覆盖类级别ApiExplorerSettings(IgnoreApi = true)

时间:2017-05-10 13:34:08

标签: c# asp.net-web-api

我有一个控制器,我在类级别声明不会出现在自动生成的API帮助页面中,如下所示:

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

现在说我想覆盖仅为ApiExplorerSettings的{​​{1}}注释,以便将其添加到文档中。我显然试过了:

method2

但无济于事。有关如何实现此行为的任何见解?
欢呼声。

1 个答案:

答案 0 :(得分:0)

如果您使用Swashbuckle生成API帮助页面,则可以使用DocumentFilter配置SwaggerGen。过滤器允许您以编程方式修改SwaggerDocument(即添加或删除某些方法),然后才能使SwaggerUI可用。

更多细节here

相关问题