代码拉取完成,页面将自动刷新
提供Knife4j、Spring Boot、Springfox、Springdoc-openapi等相关版本号信息
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
阅读issue:#IZUCU:Knife4j 提ISSUES必看
...
提供所有作者能复现此问题的步骤,包括不局限:代码、贴图、错误日志、相关中间件版本等等
@Bean
public OpenAPI openApi() {
HashMap<String, SecurityScheme> map = new HashMap<>();
map.put("clientCredentials",
new SecurityScheme().type(SecurityScheme.Type.OAUTH2)
.flows(new OAuthFlows().clientCredentials(
new OAuthFlow().tokenUrl("http://localhost:10001/oauth2/token")
.scopes(new Scopes().addString("font", "font"))
)));
map.put("password", new SecurityScheme().type(SecurityScheme.Type.OAUTH2)
.flows(new OAuthFlows().password(
new OAuthFlow().tokenUrl("http://localhost:10001/oauth2/token")
.scopes(new Scopes().addString("sys", "sys"))
)));
return new OpenAPI().info(new Info()
.title(TITLE).description(DESCRIPTION)
.termsOfService(SITE).contact(new Contact().name(DEVELOPER).url(SITE).email(EMAIL))
.version("1.0.0"))
.components(new Components().securitySchemes(map))
.addSecurityItem(new SecurityRequirement().addList("clientCredentials").addList("password"));
}
...
Swagger文档效果
Knife4j文档效果
出现问题:
1:未展示Scopes选项
2:未展示多模式
...