大摇大摆无法识别api描述

时间:2018-12-10 10:26:40

标签: spring-boot swagger springfox

我像这样{} {1}}

docket

我创建了一组存根端点,它们模仿@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.config.internal")) .paths(Predicates.or(PathSelectors.ant("/api**/**"))) .build(); } /login的真实端点。

/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(); } } 包中。

但是页面com.config.internal为空,并显示swagger ui

出什么问题了?

1 个答案:

答案 0 :(得分:0)

如果您想为上面指定的请求映射提供详尽的文档,则可以使用.paths(Predicates.or(PathSelectors.ant("/api/**")))路径匹配器对其进行简单描述。但是,如果您的路径中包含诸如api + text without backslash separator之类的更复杂的内容,那么您应该以 https://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/util/AntPathMatcher.html