mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 配置转移到 yml 文件 统一管理
This commit is contained in:
@ -21,32 +21,54 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger2的接口配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2WebMvc
|
||||
@EnableKnife4j
|
||||
public class SwaggerConfig
|
||||
{
|
||||
/** 系统基础配置 */
|
||||
public class SwaggerConfig {
|
||||
/**
|
||||
* 系统基础配置
|
||||
*/
|
||||
@Autowired
|
||||
private RuoYiConfig ruoyiConfig;
|
||||
|
||||
/** 是否开启swagger */
|
||||
/**
|
||||
* 是否开启swagger
|
||||
*/
|
||||
@Value("${swagger.enabled}")
|
||||
private boolean enabled;
|
||||
|
||||
/** 设置请求的统一前缀 */
|
||||
/**
|
||||
* 设置请求的统一前缀
|
||||
*/
|
||||
@Value("${swagger.pathMapping}")
|
||||
private String pathMapping;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Value("${swagger.title}")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Value("${swagger.description}")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
@Value("${swagger.version}")
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 创建API
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi()
|
||||
{
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
// 是否启用Swagger
|
||||
.enable(enabled)
|
||||
@ -70,8 +92,7 @@ public class SwaggerConfig
|
||||
/**
|
||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||
*/
|
||||
private List<ApiKey> securitySchemes()
|
||||
{
|
||||
private List<ApiKey> securitySchemes() {
|
||||
List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
|
||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
||||
return apiKeyList;
|
||||
@ -80,8 +101,7 @@ public class SwaggerConfig
|
||||
/**
|
||||
* 安全上下文
|
||||
*/
|
||||
private List<SecurityContext> securityContexts()
|
||||
{
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
@ -94,8 +114,7 @@ public class SwaggerConfig
|
||||
/**
|
||||
* 默认的安全上引用
|
||||
*/
|
||||
private List<SecurityReference> defaultAuth()
|
||||
{
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
@ -107,18 +126,17 @@ public class SwaggerConfig
|
||||
/**
|
||||
* 添加摘要信息
|
||||
*/
|
||||
private ApiInfo apiInfo()
|
||||
{
|
||||
private ApiInfo apiInfo() {
|
||||
// 用ApiInfoBuilder进行定制
|
||||
return new ApiInfoBuilder()
|
||||
// 设置标题
|
||||
.title("标题:若依管理系统_接口文档")
|
||||
.title(title)
|
||||
// 描述
|
||||
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||
.description(description)
|
||||
// 作者信息
|
||||
.contact(new Contact(ruoyiConfig.getName(), null, null))
|
||||
// 版本
|
||||
.version("版本号:" + ruoyiConfig.getVersion())
|
||||
.version(version)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user