TODO 暂时注释掉,for:【issues/8638】springboot3分支,knife4j不能正确显示文档,但是swagger-ui和v3/api-docs正常 #8638

springboot3
JEECG 2025-07-24 18:34:25 +08:00
parent f510578cb7
commit cf4d888839
1 changed files with 23 additions and 24 deletions

View File

@ -60,30 +60,29 @@ public class Swagger3Config implements WebMvcConfigurer {
return method -> method.isAnnotationPresent(Operation.class);
}
@Bean
public GlobalOpenApiCustomizer globalOpenApiCustomizer() {
return openApi -> {
// 全局添加鉴权参数
if (openApi.getPaths() != null) {
openApi.getPaths().forEach((path, pathItem) -> {
//log.debug("path: {}", path);
// 检查当前路径是否在排除列表中
boolean isExcluded = excludedPaths.stream().anyMatch(excludedPath ->
excludedPath.equals(path) ||
(excludedPath.endsWith("**") && path.startsWith(excludedPath.substring(0, excludedPath.length() - 2)))
);
if (!isExcluded) {
// 接口添加鉴权参数
pathItem.readOperations()
.forEach(operation ->
operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN))
);
}
});
}
};
}
//TODO 暂时注释掉for【issues/8638】springboot3分支knife4j不能正确显示文档但是swagger-ui和v3/api-docs正常 #8638
// @Bean
// public GlobalOpenApiCustomizer globalOpenApiCustomizer() {
// return openApi -> {
// // 全局添加鉴权参数
// if (openApi.getPaths() != null) {
// openApi.getPaths().forEach((path, pathItem) -> {
// //log.debug("path: {}", path);
// // 检查当前路径是否在排除列表中
// boolean isExcluded = excludedPaths.stream().anyMatch(
// excludedPath -> excludedPath.equals(path) || (excludedPath.endsWith("**") && path.startsWith(excludedPath.substring(0, excludedPath.length() - 2)))
// );
//
// if (!isExcluded) {
// // 接口添加鉴权参数
// pathItem.readOperations().forEach(operation ->
// operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN))
// );
// }
// });
// }
// };
// }
@Bean
public OpenAPI customOpenAPI() {