|
|
|
@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import springfox.documentation.builders.ApiInfoBuilder; |
|
|
|
|
import springfox.documentation.builders.PathSelectors; |
|
|
|
|
import springfox.documentation.builders.RequestHandlerSelectors; |
|
|
|
@ -16,10 +17,10 @@ import springfox.documentation.service.ApiKey; |
|
|
|
|
import springfox.documentation.service.AuthorizationScope; |
|
|
|
|
import springfox.documentation.service.Contact; |
|
|
|
|
import springfox.documentation.service.SecurityReference; |
|
|
|
|
import springfox.documentation.service.SecurityScheme; |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Swagger2的接口配置 |
|
|
|
@ -27,7 +28,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
|
|
|
* @author ruoyi |
|
|
|
|
*/ |
|
|
|
|
@Configuration |
|
|
|
|
@EnableSwagger2 |
|
|
|
|
public class SwaggerConfig |
|
|
|
|
{ |
|
|
|
|
/** 系统基础配置 */ |
|
|
|
@ -71,10 +71,10 @@ public class SwaggerConfig |
|
|
|
|
/** |
|
|
|
|
* 安全模式,这里指定token通过Authorization头请求头传递 |
|
|
|
|
*/ |
|
|
|
|
private List<ApiKey> securitySchemes() |
|
|
|
|
private List<SecurityScheme> securitySchemes() |
|
|
|
|
{ |
|
|
|
|
List<ApiKey> apiKeyList = new ArrayList<ApiKey>(); |
|
|
|
|
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); |
|
|
|
|
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); |
|
|
|
|
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); |
|
|
|
|
return apiKeyList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -87,7 +87,7 @@ public class SwaggerConfig |
|
|
|
|
securityContexts.add( |
|
|
|
|
SecurityContext.builder() |
|
|
|
|
.securityReferences(defaultAuth()) |
|
|
|
|
.forPaths(PathSelectors.regex("^(?!auth).*$")) |
|
|
|
|
.operationSelector(o -> o.requestMappingPattern().matches("/.*")) |
|
|
|
|
.build()); |
|
|
|
|
return securityContexts; |
|
|
|
|
} |
|
|
|
|