docs: 演示修改

pull/1/head
shuliYao 1 year ago
parent 9b6e6f89b9
commit bead6513e6

@ -35,13 +35,14 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
*
* @Author scott * @Author scott
*/ */
@Configuration @Configuration
@EnableSwagger2 //开启 Swagger2 @EnableSwagger2 //开启 Swagger2
@Import(BeanValidatorPluginsConfiguration.class) @Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerFlowableConfig implements WebMvcConfigurer { 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("doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
} }
/** /**
* swagger2swagger2 * swagger2swagger2
* *
@ -82,7 +83,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
.securityContexts(securityContexts()) .securityContexts(securityContexts())
.globalOperationParameters(setHeaderToken()); .globalOperationParameters(setHeaderToken());
} }
/*** /***
* oauth2 * oauth2
* swagger * swagger
@ -104,7 +105,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
pars.add(tokenPar.build()); pars.add(tokenPar.build());
return pars; return pars;
} }
/** /**
* api, * api,
* *
@ -125,7 +126,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.build(); .build();
} }
/** /**
* securityContexts * securityContexts
*/ */
@ -137,7 +138,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
.build()) .build())
); );
} }
private List<SecurityReference> defaultAuth() { private List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
@ -145,7 +146,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
return new ArrayList( return new ArrayList(
Collections.singleton(new SecurityReference(SystemConstants.X_ACCESS_TOKEN, authorizationScopes))); Collections.singleton(new SecurityReference(SystemConstants.X_ACCESS_TOKEN, authorizationScopes)));
} }
/** /**
* springboot2.6 springfox * springboot2.6 springfox
* @return * @return
@ -153,7 +154,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
@Bean @Bean
public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
return new BeanPostProcessor() { return new BeanPostProcessor() {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
@ -161,7 +162,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
} }
return bean; return bean;
} }
private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) { private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
List<T> copy = mappings.stream() List<T> copy = mappings.stream()
.filter(mapping -> mapping.getPatternParser() == null) .filter(mapping -> mapping.getPatternParser() == null)
@ -169,7 +170,7 @@ public class SwaggerFlowableConfig implements WebMvcConfigurer {
mappings.clear(); mappings.clear();
mappings.addAll(copy); mappings.addAll(copy);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) { private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
try { try {

Loading…
Cancel
Save