Swagger Spring API



我正在使用Spring Swagger库v1.0.2

Maven:

<dependency>
    <groupId>com.mangofactory</groupId>
    <artifactId>swagger-springmvc</artifactId>
    <version>1.0.2</version>
</dependency>

我能够扫描我的REST api并在Swagger UI上查看它。我甚至实现了OAuth,它工作得很好。

但是,我需要实现一个特性。我想隐藏一些REST api。我需要在类级别以及方法级别上做到这一点。我在@Api注释中看到了一个"隐藏"属性。我将其设置为"true",但我仍然可以看到我的类和它的所有方法在Swagger UI中显示。

的例子:

 @Api( 
        description="This class is not covered by Spring security.", 
        value="/unauthorize",
        hidden=true)
 @RequestMapping("/unauthorize")
 @Controller
 public class UnauthorizeResource {}

有人能告诉我如何防止' unauthorizerresource '类被显示吗?

您可以使用@ApiIgnore注释:

@ApiIgnore
@RequestMapping("/unauthorize")
@Controller
public class UnauthorizeResource {}

最新更新