Home > database >  How to tell Swagger to show any service documentation that has /api/* on its path
How to tell Swagger to show any service documentation that has /api/* on its path

Time:10-23

Im having trouble to show all my endpoints documentation, in my configuration I have the following Docket:

@Bean
    public Docket swaggerConfiguration() {
        return new Docket(DocumentationType.SWAGGER_2).select().paths(PathSelectors.ant("/api/*"))
                .apis(RequestHandlerSelectors.basePackage("com.services")).build().apiInfo(apiDetails());
    }

And the problem is that with that ant pattern, I thought the documentation of ANY kind of url would be displayed at http://localhost:8080/swagger-ui.html if it's prefixed by "/api/" which is the case for all my endpoints, but I noticed that Urls like @GetMapping("/roles/{id}") do not get documented, but urls like @GetMapping("/roles") do get documented.

Could someone please give me a hand with this config issue?

CodePudding user response:

maybe it is stupid answer but have you try to set .ant() param as

PathSelect.ant("/api/**")

Here in blog post you can find more information: https://www.vojtechruzicka.com/documenting-spring-boot-rest-api-swagger-springfox/

  • Related