diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 277cf89e5..64057d679 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -20,7 +20,7 @@ 2021.0.5 2021.0.4.0 - 3.0.3 + 4.0.0 1.6.8 2.5 @@ -191,7 +191,7 @@ com.github.xiaoymin - knife4j-spring-boot-starter + knife4j-openapi2-spring-boot-starter ${knife4j.version} diff --git a/yudao-framework/yudao-spring-boot-starter-web/pom.xml b/yudao-framework/yudao-spring-boot-starter-web/pom.xml index a04a2f1b0..790dc5ebd 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-web/pom.xml @@ -35,7 +35,7 @@ com.github.xiaoymin - knife4j-spring-boot-starter + knife4j-openapi2-spring-boot-starter io.swagger diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index 4c114b519..5ccbc06c4 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -7,18 +7,18 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.ExampleBuilder; +import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestParameterBuilder; +import springfox.documentation.schema.ModelRef; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -31,7 +31,7 @@ import static springfox.documentation.builders.RequestHandlerSelectors.basePacka * @author 芋道源码 */ @AutoConfiguration -@EnableSwagger2 +@EnableSwagger2WebMvc @EnableKnife4j @ConditionalOnClass({Docket.class, ApiInfoBuilder.class}) // 允许使用 swagger.enable=false 禁用 Swagger @@ -60,7 +60,7 @@ public class YudaoSwaggerAutoConfiguration { .securitySchemes(securitySchemes()) .securityContexts(securityContexts()) // ④ 全局参数(多租户 header) - .globalRequestParameters(globalRequestParameters()); + .globalOperationParameters(globalRequestParameters()); } // ========== apiInfo ========== @@ -96,7 +96,7 @@ public class YudaoSwaggerAutoConfiguration { return Collections.singletonList(SecurityContext.builder() .securityReferences(securityReferences()) // 通过 PathSelectors.regex("^(?!auth).*$"),排除包含 "auth" 的接口不需要使用securitySchemes - .operationSelector(o -> o.requestMappingPattern().matches("^(?!auth).*$")) + .forPaths(PathSelectors.regex("^(?!auth).*$")) .build()); } @@ -110,11 +110,17 @@ public class YudaoSwaggerAutoConfiguration { // ========== globalRequestParameters ========== - private static List globalRequestParameters() { - RequestParameterBuilder tenantParameter = new RequestParameterBuilder() - .name(HEADER_TENANT_ID).description("租户编号") - .in(ParameterType.HEADER).example(new ExampleBuilder().value(1L).build()); - return Collections.singletonList(tenantParameter.build()); + private static List globalRequestParameters() { + List tenantParameter = new ArrayList<>(); + tenantParameter.add(new ParameterBuilder() + .name(HEADER_TENANT_ID) + .description("租户编号") + .modelRef(new ModelRef("long")) + .defaultValue("1") + .parameterType("header") + .required(true) + .build()); + return tenantParameter; } } diff --git a/yudao-gateway/pom.xml b/yudao-gateway/pom.xml index 45ebc2ece..a0a03fd6d 100644 --- a/yudao-gateway/pom.xml +++ b/yudao-gateway/pom.xml @@ -46,7 +46,7 @@ com.github.xiaoymin - knife4j-spring-boot-starter + knife4j-openapi2-spring-boot-starter io.swagger