diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 31d0de5f..f599a847 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -204,8 +204,13 @@ mybatis-encryptor: publicKey: privateKey: -# Swagger配置 -swagger: +springdoc: + api-docs: + # 是否开启接口文档 + enabled: true + swagger-ui: + # 持久化认证数据 + persistAuthorization: true info: # 标题 title: '标题:${ruoyi.name}多租户管理系统_接口文档' @@ -225,14 +230,6 @@ swagger: type: APIKEY in: HEADER name: ${sa-token.token-name} - -springdoc: - api-docs: - # 是否开启接口文档 - enabled: true - swagger-ui: - # 持久化认证数据 - persistAuthorization: true #这里定义了两个分组,可定义多个,也可以不定义 group-configs: - group: 1.演示模块 diff --git a/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SwaggerConfig.java b/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SpringDocConfig.java similarity index 92% rename from ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SwaggerConfig.java rename to ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SpringDocConfig.java index 459941c9..4e323800 100644 --- a/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SwaggerConfig.java +++ b/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/SpringDocConfig.java @@ -1,13 +1,13 @@ package org.dromara.common.doc.config; -import org.dromara.common.core.utils.StringUtils; -import org.dromara.common.doc.config.properties.SwaggerProperties; -import org.dromara.common.doc.handler.OpenApiHandler; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Paths; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.security.SecurityRequirement; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.doc.config.properties.SpringDocProperties; +import org.dromara.common.doc.handler.OpenApiHandler; import org.springdoc.core.configuration.SpringDocConfiguration; import org.springdoc.core.customizers.OpenApiBuilderCustomizer; import org.springdoc.core.customizers.OpenApiCustomizer; @@ -36,18 +36,18 @@ import java.util.Set; */ @RequiredArgsConstructor @AutoConfiguration(before = SpringDocConfiguration.class) -@EnableConfigurationProperties(SwaggerProperties.class) +@EnableConfigurationProperties(SpringDocProperties.class) @ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true) -public class SwaggerConfig { +public class SpringDocConfig { private final ServerProperties serverProperties; @Bean @ConditionalOnMissingBean(OpenAPI.class) - public OpenAPI openApi(SwaggerProperties swaggerProperties) { + public OpenAPI openApi(SpringDocProperties swaggerProperties) { OpenAPI openApi = new OpenAPI(); // 文档基本信息 - SwaggerProperties.InfoProperties infoProperties = swaggerProperties.getInfo(); + SpringDocProperties.InfoProperties infoProperties = swaggerProperties.getInfo(); Info info = convertInfo(infoProperties); openApi.info(info); // 扩展文档信息 @@ -65,7 +65,7 @@ public class SwaggerConfig { return openApi; } - private Info convertInfo(SwaggerProperties.InfoProperties infoProperties) { + private Info convertInfo(SpringDocProperties.InfoProperties infoProperties) { Info info = new Info(); info.setTitle(infoProperties.getTitle()); info.setDescription(infoProperties.getDescription()); diff --git a/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SwaggerProperties.java b/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SpringDocProperties.java similarity index 95% rename from ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SwaggerProperties.java rename to ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SpringDocProperties.java index 9e08e739..eae3b4c6 100644 --- a/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SwaggerProperties.java +++ b/ruoyi-common/ruoyi-common-doc/src/main/java/org/dromara/common/doc/config/properties/SpringDocProperties.java @@ -18,8 +18,8 @@ import java.util.List; * @author Lion Li */ @Data -@ConfigurationProperties(prefix = "swagger") -public class SwaggerProperties { +@ConfigurationProperties(prefix = "springdoc") +public class SpringDocProperties { /** * 文档基本信息 diff --git a/ruoyi-common/ruoyi-common-doc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-doc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index e64b2eb3..fe11e76e 100644 --- a/ruoyi-common/ruoyi-common-doc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-common/ruoyi-common-doc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1 @@ -org.dromara.common.doc.config.SwaggerConfig +org.dromara.common.doc.config.SpringDocConfig