Swagger Spring API

Raj*_*Raj 7 java spring-mvc swagger swagger-ui

我正在使用Spring Swagger库v1.0.2

Maven的:

<dependency>
    <groupId>com.mangofactory</groupId>
    <artifactId>swagger-springmvc</artifactId>
    <version>1.0.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我能够扫描我的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 {}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我如何阻止显示"UnauthorizeResource"类吗?

Dra*_*vic 15

您可以使用@ApiIgnore注释:

@ApiIgnore
@RequestMapping("/unauthorize")
@Controller
public class UnauthorizeResource {}
Run Code Online (Sandbox Code Playgroud)