POC showing how to divide endpoint(s) among different Open-API screens
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.10</version>
</dependency>
springdoc.api-docs.groups.enabled=true
- com.behl.controller.nsfw
- put endpoint(s) that belong in 'nsfw' group here
- com.behl.controller.sfw
- put endpoint(s) that belong in 'sfw' group here
@Bean
public GroupedOpenApi nsfwOpenApi() {
String packagesToscan[] = { "com.behl.agares.controller.nsfw" };
return GroupedOpenApi.builder().group("nsfw")
.packagesToScan(packagesToscan).build();
}
@Configuration
public class NsfwOpenApiCustomizer implements OpenApiCustomiser {
@Override
public void customise(final OpenAPI openApi) {
final var info = new Info().title("Not Safe For Work Joke API").version("1.0")
.description("Endpoint(s) to expose to mature audience")
.contact(new Contact().email("[email protected]").name("Hardik Singh Behl")
.url("https://www.linkedin.com/in/hardiksinghbehl/"));
openApi.info(info);
}
}
Pass the class implementing OpenApiCustomizer in the .addOpenApiCustomiser(OpenApiCustomizer) method in the earlier created GroupedOpenApi Bean
@Bean
public GroupedOpenApi sfwOpenApi() {
String packagesToscan[] = { "com.behl.agares.controller.sfw" };
return GroupedOpenApi.builder().group("sfw").addOpenApiCustomiser(nsfwOpenApiCustomizer)
.packagesToScan(packagesToscan).build();
}
http://server:port/swagger-ui.html
http://localhost:8080/swagger-ui.html