From bead6513e6aa76c5efb7fbda711755d3a866d2c1 Mon Sep 17 00:00:00 2001 From: shuliYao <1397940314@qq.com> Date: Thu, 28 Mar 2024 13:28:08 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=BC=94=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jyjz/xiaoyao/SwaggerFlowableConfig.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/runstart/src/main/java/cn/jyjz/xiaoyao/SwaggerFlowableConfig.java b/runstart/src/main/java/cn/jyjz/xiaoyao/SwaggerFlowableConfig.java index 96899262..c37917a0 100644 --- a/runstart/src/main/java/cn/jyjz/xiaoyao/SwaggerFlowableConfig.java +++ b/runstart/src/main/java/cn/jyjz/xiaoyao/SwaggerFlowableConfig.java @@ -35,13 +35,14 @@ import java.util.List; import java.util.stream.Collectors; /** + * 做个测试 * @Author scott */ @Configuration @EnableSwagger2 //开启 Swagger2 @Import(BeanValidatorPluginsConfiguration.class) public class SwaggerFlowableConfig implements WebMvcConfigurer { - + /** * 导入配置文件中的值 */ @@ -59,7 +60,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } - + /** * swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 * @@ -82,7 +83,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { .securityContexts(securityContexts()) .globalOperationParameters(setHeaderToken()); } - + /*** * oauth2配置 * 需要增加swagger授权回调地址 @@ -104,7 +105,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { pars.add(tokenPar.build()); return pars; } - + /** * api文档的详细信息函数,注意这里的注解引用的是哪个 * @@ -125,7 +126,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") .build(); } - + /** * 新增 securityContexts 保持登录状态 */ @@ -137,7 +138,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { .build()) ); } - + private List defaultAuth() { AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; @@ -145,7 +146,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { return new ArrayList( Collections.singleton(new SecurityReference(SystemConstants.X_ACCESS_TOKEN, authorizationScopes))); } - + /** * 解决springboot2.6 和springfox不兼容问题 * @return @@ -153,7 +154,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { @Bean public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { return new BeanPostProcessor() { - + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { @@ -161,7 +162,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { } return bean; } - + private void customizeSpringfoxHandlerMappings(List mappings) { List copy = mappings.stream() .filter(mapping -> mapping.getPatternParser() == null) @@ -169,7 +170,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer { mappings.clear(); mappings.addAll(copy); } - + @SuppressWarnings("unchecked") private List getHandlerMappings(Object bean) { try {