shoaib1992
shoaib1992

Reputation: 420

Spring Boot Swagger: How to ignore certain API's from swagger based on spring profile?

Currently, there are certain private API's in my controller class which I need to ignore them in my production environment, whereas needed in the QA and Dev environments.

I'm using @ApiIgnore annotation from spring fox to achieve this on a global level. Is there a way where I can execute this annotation based on spring boot environment variable?

Or any other solution to tackle this problem ?

Upvotes: 3

Views: 2694

Answers (1)

Anand Kulkarni
Anand Kulkarni

Reputation: 1201

You can use

@Autowired private Environment environment; 
....
this.environment.getActiveProfiles();

to get the current profile and then create Docket objects in your swagger configuration class based on the active profile.

Upvotes: 2

Related Questions