0
votes

I tried using swagger, spring-rest-doc and spring-fox to generate documentation for spring mvc based rest services. However, my challenge is to document spring security xml configuration based endpoints. So far spring-fox has been the winner. But it documents all of the methods that spring security supports. Any ideas on how to filter out the ones I need?

For instance, when I use /swagger-ui.html to pull up the documentation page I see the following groups:

  • basic-error-controller
  • authorization-endpoint
  • whitelabel-approval-endpoint
  • health-checker

Of which I only need authorization-endpoint and health-checker. Any ideas?

1

1 Answers

0
votes

Have you looked at the documentation to transition to 2.0?

@Bean
public Docket swaggerSpringMvcPlugin() {
    return new Docket(DocumentationType.SWAGGER_2)
        .groupName("business-api")
        .select() 
           //Ignores controllers annotated with @CustomIgnore
          .apis(not(withClassAnnotation(CustomIgnore.class)) 
          // and by paths
          .paths(paths()) 
          .build()
        .apiInfo(apiInfo())
        .securitySchemes(securitySchemes())
        .securityContext(securityContext());
}

You should be able to use the RequestHandlerSelectors to filter the apis you need using the following predicates

  • class annotations like the example show above withClassAnnotation
  • method annotations (for filtering operations) withMethodAnnotation
  • by base package basePackage

I suspect you've already figured out how to get it to work with xml configuration (in which case the title of this question is incorrect). In case you need more examples there is also plenty of demos and examples. If you have any more questions, the issue tracker is probably a better place than stackoverflow.com which we dont frequent as often.