diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 8c0b6e432..dcc0c020e 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -219,12 +219,13 @@ swagger: enabled: true # 请求前缀 pathMapping: /dev-api - # 标题 - title: '标题:${ruoyi.name}后台管理系统_接口文档' - # 描述 - description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...' - # 版本 - version: '版本号: ${ruoyi-vue-plus.version}' + info: + # 标题 + title: '标题:${ruoyi.name}后台管理系统_接口文档' + # 描述 + description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...' + # 版本 + version: '版本号: ${ruoyi-vue-plus.version}' # 作者信息 contact: name: Lion Li @@ -233,6 +234,18 @@ swagger: groups: - name: 1.演示案例 basePackage: com.ruoyi.demo + info: + # 标题 + title: '标题:${ruoyi.name}后台管理系统_案例演示' + # 描述 + description: '描述:用于演示框架各种常用功能' + # 版本 + version: '版本号: ${ruoyi-vue-plus.version}' + # 作者信息 + contact: + name: Lion Li, Xiao Xie + email: crazylionli@163.com + url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus - name: 2.系统模块 basePackage: com.ruoyi.web - name: 3.代码生成模块 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java index 22ef7c1b5..58efe131e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java @@ -84,7 +84,7 @@ public class SwaggerConfig { Docket docket = new Docket(DocumentationType.OAS_30) .enable(swaggerProperties.getEnabled()) // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) - .apiInfo(apiInfo()) + .apiInfo(apiInfo(group.getInfo(), group.getContact())) // 设置哪些接口暴露给Swagger展示 .select() // 扫描所有有注解的api,用这种方式更灵活 @@ -143,18 +143,18 @@ public class SwaggerConfig { /** * 添加摘要信息 */ - private ApiInfo apiInfo() { + private ApiInfo apiInfo(SwaggerProperties.Info info, SwaggerProperties.Contact contact) { + info = info != null ? info : swaggerProperties.getInfo(); // 用ApiInfoBuilder进行定制 - SwaggerProperties.Contact contact = swaggerProperties.getContact(); - return new ApiInfoBuilder() + contact = contact != null ? contact : swaggerProperties.getContact();return new ApiInfoBuilder() // 设置标题 - .title(swaggerProperties.getTitle()) + .title(info.getTitle()) // 描述 - .description(swaggerProperties.getDescription()) + .description(info.getDescription()) // 作者信息 .contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail())) // 版本 - .version(swaggerProperties.getVersion()) + .version(info.getVersion()) .build(); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java index c2b3f97b6..fac14d147 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java @@ -18,25 +18,19 @@ import java.util.List; public class SwaggerProperties { /** - * 验证码类型 + * API文档开关 */ private Boolean enabled; + /** * 设置请求的统一前缀 */ private String pathMapping; + /** - * 验证码类别 + * 文档基本信息 */ - private String title; - /** - * 数字验证码位数 - */ - private String description; - /** - * 字符验证码长度 - */ - private String version; + private Info info; /** * 联系方式 @@ -48,6 +42,23 @@ public class SwaggerProperties { */ private List groups; + @Data + @NoArgsConstructor + public static class Info { + /** + * API文档标题 + */ + private String title = ""; + /** + * 摘要 + */ + private String description=""; + /** + * 版本 + */ + private String version=""; + } + @Data @NoArgsConstructor public static class Contact { @@ -83,6 +94,16 @@ public class SwaggerProperties { */ private String basePackage; + /** + * 模块基本信息 + */ + private Info info; + + /** + * 联系方式 + */ + private Contact contact; + } }