After you delve into the springfox documentation and discard some dead end ideas, I come up with two solutions that can solve your problem. Apply and mix them according to your needs.
Tip # 1 - Filter Using RequestHandlerSelectors
Tell springfox which endpoint method you would like to show in swagger-ui. Therefore, you can configure RequestHandlerSelectorto scan the entire application, a specific package, or classes and methods that you annotated with the annotation.
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).paths(PathSelectors.any())
.build();
}
public interface QueuedMessageDao extends CrudRepository<QueuedMessage, Integer> {
@ApiOperation(value = "This method finds all messages that are queued with the recipient email address")
List<QueuedMessage> findByRecipientEmail(String email);
}
spring -data-rest swagger. () HTTP- swagger-ui, GET, HEAD OPTIONS /<entity>/search. , , .
# 2 - PathSelectors
/<entity>/search swagger, , , , . , GET.
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).paths(PathSelectors.regex("^(?!(/.*(/search)$)).*$"))
.build();
}
public interface QueuedMessageDao extends CrudRepository<QueuedMessage, Integer> {
@ApiOperation(value = "this generates a business search endpoint")
List<QueuedMessage> findById(int id);
@ApiOperation(value = "This method finds all messages that are queued with the recipient email address")
List<QueuedMessage> findByRecipientEmail(String email);
}
, - swagger.
, !