diff --git a/mall-oms/oms-boot/pom.xml b/mall-oms/oms-boot/pom.xml
index 41db2efe12084fe8bf4a10bcad21dc446057a714..063adcb7dcd36939b0bf0f31f3c01c780a0bc983 100644
--- a/mall-oms/oms-boot/pom.xml
+++ b/mall-oms/oms-boot/pom.xml
@@ -48,7 +48,10 @@
- * Spring Doc FAQ: https://springdoc.org/#faq
- *
- * @author haoxr
- * @since 2023/2/17
- */
-@Configuration
-public class SwaggerConfig {
-
- /**
- * 认证服务地址
- */
- @Value("${knife4j.oauth2.token-url}")
- private String tokenUrl ;
-
- /**
- * 接口信息
- */
- @Bean
- public OpenAPI apiInfo() {
- return new OpenAPI()
- .components(new Components()
- .addSecuritySchemes("Authorization",
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.OAUTH2)
- .flows(new OAuthFlows()
- .password(
- new io.swagger.v3.oas.models.security.OAuthFlow()
- .tokenUrl(tokenUrl)
- .refreshUrl(tokenUrl)
- .scopes(
- new Scopes()
- .addString("all", "全部权限")
- )
- )
- )
- .scheme("bearer")
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- )
- )
- .info(new Info()
- .title("订单服务")
- .version("3.0.0")
- .description("订单、购物车等接口")
- .license(new License().name("Apache 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0"))
- );
- }
-
-
-}
diff --git a/mall-pms/pms-boot/pom.xml b/mall-pms/pms-boot/pom.xml
index b8f3b3e2dc96f313754077dac64ca7edc46ea5e0..fa3dfa9dff9d47bc65a19bcb027b2eea470fac41 100644
--- a/mall-pms/pms-boot/pom.xml
+++ b/mall-pms/pms-boot/pom.xml
@@ -92,6 +92,11 @@
- * Spring Doc FAQ: https://springdoc.org/#faq
- *
- * @author haoxr
- * @since 2023/2/17
- */
-@Configuration
-public class SwaggerConfig {
-
- /**
- * 认证服务地址
- */
- @Value("${knife4j.oauth2.token-url}")
- private String tokenUrl ;
-
- /**
- * 接口信息
- */
- @Bean
- public OpenAPI apiInfo() {
- return new OpenAPI()
- .components(new Components()
- .addSecuritySchemes("Authorization",
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.OAUTH2)
- .flows(new OAuthFlows()
- .password(
- new io.swagger.v3.oas.models.security.OAuthFlow()
- .tokenUrl(tokenUrl)
- .refreshUrl(tokenUrl)
- .scopes(
- new Scopes()
- .addString("all", "全部权限")
- )
- )
- )
- .scheme("bearer")
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- )
- )
- .info(new Info()
- .title("商品服务")
- .version("3.0.0")
- .description("库存、分类、品牌、规格、参数等接口")
- .license(new License().name("Apache 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0"))
- );
- }
-
-
-
-}
diff --git a/mall-sms/sms-boot/pom.xml b/mall-sms/sms-boot/pom.xml
index 4ba08308fa306b4e099259c8fd0fe4f2276e7516..d2584df7c5bdb6a6c07405ee209cb2c6baee519d 100644
--- a/mall-sms/sms-boot/pom.xml
+++ b/mall-sms/sms-boot/pom.xml
@@ -79,13 +79,13 @@
- * Spring Doc FAQ: https://springdoc.org/#faq
- *
- * @author haoxr
- * @since 2023/2/17
- */
-@Configuration
-public class SwaggerConfig {
-
- /**
- * 认证服务地址
- */
- @Value("${knife4j.oauth2.token-url}")
- private String tokenUrl ;
-
- /**
- * 接口信息
- */
- @Bean
- public OpenAPI apiInfo() {
- return new OpenAPI()
- .components(new Components()
- .addSecuritySchemes("Authorization",
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.OAUTH2)
- .flows(new OAuthFlows()
- .password(
- new io.swagger.v3.oas.models.security.OAuthFlow()
- .tokenUrl(tokenUrl)
- .refreshUrl(tokenUrl)
- .scopes(
- new Scopes()
- .addString("all", "全部权限")
- )
- )
- )
- .scheme("bearer")
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- )
- )
- .info(new Info()
- .title("营销服务")
- .version("3.0.0")
- .description("广告、优惠券等接口")
- .license(new License().name("Apache 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0"))
- );
- }
-
-}
diff --git a/mall-ums/ums-boot/pom.xml b/mall-ums/ums-boot/pom.xml
index 5331669aaa29671c5247b10f10bc5a9c5c119531..0030b8c88b9e9479fc49dec93ee1b67e671ba86c 100644
--- a/mall-ums/ums-boot/pom.xml
+++ b/mall-ums/ums-boot/pom.xml
@@ -78,6 +78,11 @@
- * Spring Doc FAQ: https://springdoc.org/#faq
- *
- * @author haoxr
- * @since 2023/2/17
- */
-@Configuration
-public class SwaggerConfig {
-
-
- /**
- * 认证服务地址
- */
- @Value("${knife4j.oauth2.token-url}")
- private String tokenUrl ;
-
- /**
- * 接口信息
- */
- @Bean
- public OpenAPI apiInfo() {
- return new OpenAPI()
- .components(new Components()
- .addSecuritySchemes("Authorization",
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.OAUTH2)
- .flows(new OAuthFlows()
- .password(
- new io.swagger.v3.oas.models.security.OAuthFlow()
- .tokenUrl(tokenUrl)
- .refreshUrl(tokenUrl)
- .scopes(
- new Scopes()
- .addString("all", "全部权限")
- )
- )
- )
- .scheme("bearer")
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- )
- )
- .info(new Info()
- .title("会员服务")
- .version("3.0.0")
- .description("会员、地址等接口")
- .license(new License().name("Apache 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0"))
- );
- }
-
-}
diff --git a/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfig.java b/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfig.java
deleted file mode 100644
index 39b124dcbf8b52b87cddf63b60558a576d5ebd9b..0000000000000000000000000000000000000000
--- a/youlai-auth/src/main/java/com/youlai/auth/config/SwaggerConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.youlai.auth.config;
-
-import io.swagger.v3.oas.models.Components;
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.info.Info;
-import io.swagger.v3.oas.models.info.License;
-import io.swagger.v3.oas.models.security.OAuthFlows;
-import io.swagger.v3.oas.models.security.Scopes;
-import io.swagger.v3.oas.models.security.SecurityScheme;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Swagger 配置
- *
- * @author haoxr
- * @since 2023/2/17
- */
-@Configuration
-public class SwaggerConfig {
-
- /**
- * 认证服务地址
- */
- @Value("${knife4j.oauth2.token-url}")
- private String tokenUrl ;
-
- /**
- * 接口信息
- */
- @Bean
- public OpenAPI apiInfo() {
- return new OpenAPI()
- .components(new Components()
- .addSecuritySchemes("Authorization",
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.OAUTH2)
- .flows(new OAuthFlows()
- .password(
- new io.swagger.v3.oas.models.security.OAuthFlow()
- .tokenUrl(tokenUrl)
- .refreshUrl(tokenUrl)
- .scopes(
- new Scopes()
- .addString("all", "全部权限")
- )
- )
- )
- .scheme("bearer")
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- )
- )
- .info(new Info()
- .title("认证中心")
- .version("3.0.0")
- .description("认证接口")
- .license(new License().name("Apache 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0"))
- );
- }
-
-}
diff --git a/youlai-common/common-apidoc/pom.xml b/youlai-common/common-apidoc/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7aa31aada90a146b1d072af002ae7840dccf5d71
--- /dev/null
+++ b/youlai-common/common-apidoc/pom.xml
@@ -0,0 +1,36 @@
+
+
+ * 基于 OpenAPI 3.0 规范 + SpringDoc 实现 + knife4j 增强
+ *
+ * @author haoxr
+ * @since 3.0.0
+ */
+@Configuration
+@RequiredArgsConstructor
+@EnableConfigurationProperties(ApiDocInfoProperties.class)
+public class OpenApiConfig {
+
+ /**
+ * OAuth2 认证 endpoint
+ */
+ @Value("${spring.security.oauth2.authorizationserver.token-uri}")
+ private String tokenUrl;
+
+ /**
+ * API 文档信息属性
+ */
+ private final ApiDocInfoProperties apiDocInfoProperties;
+
+
+ /**
+ * OpenAPI 配置(元信息、安全协议)
+ */
+ @Bean
+ public OpenAPI apiInfo() {
+ return new OpenAPI()
+ .components(new Components()
+ .addSecuritySchemes(HttpHeaders.AUTHORIZATION,
+ new SecurityScheme()
+ // OAuth2 授权模式
+ .type(SecurityScheme.Type.OAUTH2)
+ .name(HttpHeaders.AUTHORIZATION)
+ .flows(new OAuthFlows()
+ .password(
+ new OAuthFlow()
+ .tokenUrl(tokenUrl)
+ .refreshUrl(tokenUrl)
+ )
+ )
+ // 安全模式使用Bearer令牌(即JWT)
+ .in(SecurityScheme.In.HEADER)
+ .scheme("Bearer")
+ .bearerFormat("JWT")
+ )
+ )
+ // 接口全局添加 Authorization 参数
+ .addSecurityItem(new SecurityRequirement().addList(HttpHeaders.AUTHORIZATION))
+ // 接口文档信息(不重要)
+ .info(new Info()
+ .title(apiDocInfoProperties.getTitle())
+ .version(apiDocInfoProperties.getVersion())
+ .description(apiDocInfoProperties.getDescription())
+ .contact(new Contact()
+ .name(apiDocInfoProperties.getContact().getName())
+ .url(apiDocInfoProperties.getContact().getUrl())
+ .email(apiDocInfoProperties.getContact().getEmail())
+ )
+ .license(new License().name(apiDocInfoProperties.getLicense().getName())
+ .url(apiDocInfoProperties.getLicense().getUrl())
+ ));
+ }
+
+}
diff --git a/youlai-common/common-apidoc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/youlai-common/common-apidoc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000000000000000000000000000000000000..3af97aff5a7fcef48d9efb6bbc3ff9a231e848b8
--- /dev/null
+++ b/youlai-common/common-apidoc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+ com.youlai.common.apidoc.config.OpenApiConfig
diff --git a/youlai-common/common-web/pom.xml b/youlai-common/common-web/pom.xml
index db690160aebaa2ac4f4e44fe17a9b352b373a28b..0ca6148f1d7cbe8844c46d66b0b33d7efbe9ad0d 100644
--- a/youlai-common/common-web/pom.xml
+++ b/youlai-common/common-web/pom.xml
@@ -12,6 +12,7 @@