Vla*_*ier 7 java swagger swagger-ui spring-boot springfox
我的项目中的 Swagger 文档有多个组。每个组都有一个Docket端点(每个组的成员)都用自定义注释进行标记。例如,这里是Docket身份验证组:
@Bean
public Docket authenticationApis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("authentication")
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(AuthenticationApiGroup.class))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo())
.securitySchemes(Collections.singletonList(securityScheme()))
.securityContexts(Collections.singletonList(securityContext()));
}
Run Code Online (Sandbox Code Playgroud)
Docket所有可用端点还有一个(默认) 。问题是,当我调用文档 URL 时,Swagger UI 默认加载最上面的组.../swagger-ui.html。就我而言,它是身份验证组,因为这些组是按字母顺序排序的。所需的行为是将默认组加载为默认 API 组。我怎样才能做到这一点?
我尝试用 来命名默认值Docket,因此.groupName("all")它是最顶层的组(all < authentication),但这个解决方案有点“脏”,在这种情况下,文档将有两个重复的组(all和default)。
Springfox 2.9.2项目中使用。
| 归档时间: |
|
| 查看次数: |
4766 次 |
| 最近记录: |