I am working on Spring Boot v2.2.2.RELEASE and SpringDoc UI and Open API Specification OAS3
and I found very related question here: https://github.com/springdoc/springdoc-openapi/issues/201.
I've 4 Profiles say Dev, Stage, UAT and Prod and say I've Student API, Employee API and Department API.
I want for UAT and Prod profiles, I want to hide Department API. How can we do not ?
You can use groups: Declare each of your API in groups.
And, add the @Profile annotation together with @Bean annotation for the group definition: This will help you display the OpenAPI spec depending on your spring profiles
@Bean
@Profile("!prod")
public GroupedOpenApi actuatorApi() {
return GroupedOpenApi.builder().group("Actuator")
.pathsToMatch("/actuator/**")
.pathsToExclude("/actuator/health/*")
.build();
}