From 7d5007045140ed3ff77663c2ef51c03809e27ac1 Mon Sep 17 00:00:00 2001 From: TanYibin <5491541@qq.com> Date: Tue, 28 Feb 2023 14:28:57 +0800 Subject: [PATCH] 暂时注释Swagger3 --- huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java index 4570239..df065e0 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/Swagger3Config.java @@ -34,70 +34,70 @@ import springfox.documentation.spring.web.plugins.Docket; //@Import(BeanValidatorPluginsConfiguration.class) public class Swagger3Config implements WebMvcConfigurer { - /** - * 显示swagger-ui.html文档展示页,还必须注入swagger资源: - * @param registry - */ - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - - /** - * swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 - * @return Docket - */ - @Bean(value = "defaultApi2") - public Docket defaultApi2() { - return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() - // 此包路径下的类,才生成接口文档 - .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules.wms.api")) - // 加了ApiOperation注解的类,才生成接口文档 - .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)).apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - .paths(PathSelectors.any()).build().securitySchemes(Collections.singletonList(securityScheme())).securityContexts(securityContexts()); - // .globalOperationParameters(setHeaderToken()); - } - - /*** - * oauth2配置 - * 需要增加swagger授权回调地址 - * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html - * @return - */ - @Bean - SecurityScheme securityScheme() { - return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header"); - } - - /** - * 新增 securityContexts 保持登录状态 - */ - private List<SecurityContext> securityContexts() { - return Collections.singletonList(SecurityContext.builder().securityReferences(defaultAuth()).forPaths(PathSelectors.regex("^(?!auth).*$")).build()); - } - - /** - * api文档的详细信息函数,注意这里的注解引用的是哪个 - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - // //大标题 - .title("华恒仓储管理系统API接口文档") - // 版本号 - .version("1.0") -// .termsOfServiceUrl("NO terms of service") - // 描述 - .description("后台API接口").license("The Apache License, Version 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").build(); - } - - private List<SecurityReference> defaultAuth() { - AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; - authorizationScopes[0] = authorizationScope; - return Collections.singletonList(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)); - } +// /** +// * 显示swagger-ui.html文档展示页,还必须注入swagger资源: +// * @param registry +// */ +// @Override +// public void addResourceHandlers(ResourceHandlerRegistry registry) { +// registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); +// registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); +// registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); +// } +// +// /** +// * swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 +// * @return Docket +// */ +// @Bean(value = "defaultApi2") +// public Docket defaultApi2() { +// return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() +// // 此包路径下的类,才生成接口文档 +// .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules.wms.api")) +// // 加了ApiOperation注解的类,才生成接口文档 +// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)).apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) +// .paths(PathSelectors.any()).build().securitySchemes(Collections.singletonList(securityScheme())).securityContexts(securityContexts()); +// // .globalOperationParameters(setHeaderToken()); +// } +// +// /*** +// * oauth2配置 +// * 需要增加swagger授权回调地址 +// * http://localhost:8888/webjars/springfox-swagger-ui/o2c.html +// * @return +// */ +// @Bean +// SecurityScheme securityScheme() { +// return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header"); +// } +// +// /** +// * 新增 securityContexts 保持登录状态 +// */ +// private List<SecurityContext> securityContexts() { +// return Collections.singletonList(SecurityContext.builder().securityReferences(defaultAuth()).forPaths(PathSelectors.regex("^(?!auth).*$")).build()); +// } +// +// /** +// * api文档的详细信息函数,注意这里的注解引用的是哪个 +// * @return +// */ +// private ApiInfo apiInfo() { +// return new ApiInfoBuilder() +// // //大标题 +// .title("华恒仓储管理系统API接口文档") +// // 版本号 +// .version("1.0") +//// .termsOfServiceUrl("NO terms of service") +// // 描述 +// .description("后台API接口").license("The Apache License, Version 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html").build(); +// } +// +// private List<SecurityReference> defaultAuth() { +// AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); +// AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; +// authorizationScopes[0] = authorizationScope; +// return Collections.singletonList(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)); +// } } -- libgit2 0.22.2