Raj
Raj

Reputation: 1148

Swagger Spring API

I am using Spring Swagger library v1.0.2

Maven:

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

I am able to scan my REST APIs and view it on the Swagger UI. I have even implemented OAuth and it is working great.

However, there is one feature that I need to implement. I want to hide some of the REST APIs. I need to do this at the class level as well as on the method level. I read about an 'hidden' attribute in the @Api annotation. I set it to 'true' but I can still see my class and all its method being displayed in the Swagger UI.

Example:

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

Can someone please tell me how I can prevent the 'UnauthorizeResource' class from being displayed?

Upvotes: 10

Views: 14006

Answers (1)

Dragan Bozanovic
Dragan Bozanovic

Reputation: 23562

You can utilize the @ApiIgnore annotation:

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

Upvotes: 20

Related Questions