0

I instatiate docket like this

@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.config.internal"))
        .paths(Predicates.or(PathSelectors.ant("/api**/**")))
        .build();
}

I created a set of stub endpoints that imitate the real one for /login or /oauth.

@Api("Authentication")
@RequestMapping("/api")
public interface LoginEndpointApi {

    @ApiOperation(value = "Github SSO endpoint", notes = "Endpoint for Github SSO authentication")
    @ApiResponses({
        @ApiResponse(code = 200, message = "HTML page of main application")
    })
    @GetMapping("/oauth/github")
    default void oauthGithub() {
        throw new UnsupportedOperationException();
    }

    @ApiOperation(value = "Get CSRF token", notes = "Returns current CSRF token")
    @ApiResponses({
        @ApiResponse(code = 200, message = "CSRF token response", response = String.class,
            examples = @Example({@ExampleProperty(value = "015275eb-293d-4ce9-ba07-ff5e1c348092")}))
    })
    @GetMapping("/csrf-token")
    default void csrfToken() {
        throw new UnsupportedOperationException();
    }

    @ApiOperation(value = "Login endpoint", notes = "Login endpoint for authorization")
    @ApiResponses({
        @ApiResponse(code = 200, message = "Successful authentication")
    })
    @PostMapping("/login")
    default void login(
            @ApiParam(required = true, name = "login", value = "login body")
            @RequestBody LoginRequest loginRequest) {
        throw new UnsupportedOperationException();
    }
}

But it doesn't recognize it. It is located in the same com.config.internal package as I described.

But the page swagger ui is empty and shows that No operations defined in spec!

What is the problem?

lapots
  • 12,553
  • 32
  • 121
  • 242

1 Answers1

0

If you want to provide swagger documentation for your request mappings specified above you could simply describe it with .paths(Predicates.or(PathSelectors.ant("/api/**"))) path matchers. But if your path includes something more complicated like api + text without backslash separator then you should get known with https://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/util/AntPathMatcher.html

Serg Vasylchak
  • 858
  • 4
  • 18