Commit 88ce5e540e06f3f49383ba0fd93936e55654ad45
1 parent
9fc6e0f0
refactor: springdoc 替换 springfox
Showing
4 changed files
with
27 additions
and
17 deletions
yudao-dependencies/pom.xml
| @@ -165,7 +165,7 @@ | @@ -165,7 +165,7 @@ | ||
| 165 | 165 | ||
| 166 | <dependency> | 166 | <dependency> |
| 167 | <groupId>org.springdoc</groupId> | 167 | <groupId>org.springdoc</groupId> |
| 168 | - <artifactId>springdoc-openapi-javadoc</artifactId> | 168 | + <artifactId>springdoc-openapi-ui</artifactId> |
| 169 | <version>${springdoc.version}</version> | 169 | <version>${springdoc.version}</version> |
| 170 | </dependency> | 170 | </dependency> |
| 171 | 171 |
yudao-framework/yudao-common/pom.xml
| @@ -63,11 +63,6 @@ | @@ -63,11 +63,6 @@ | ||
| 63 | <artifactId>springdoc-openapi-webmvc-core</artifactId> | 63 | <artifactId>springdoc-openapi-webmvc-core</artifactId> |
| 64 | </dependency> | 64 | </dependency> |
| 65 | 65 | ||
| 66 | - <dependency> | ||
| 67 | - <groupId>org.springdoc</groupId> | ||
| 68 | - <artifactId>springdoc-openapi-javadoc</artifactId> | ||
| 69 | - </dependency> | ||
| 70 | - | ||
| 71 | <!-- 监控相关 --> | 66 | <!-- 监控相关 --> |
| 72 | <dependency> | 67 | <dependency> |
| 73 | <groupId>org.apache.skywalking</groupId> | 68 | <groupId>org.apache.skywalking</groupId> |
yudao-framework/yudao-spring-boot-starter-web/pom.xml
| @@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
| 40 | 40 | ||
| 41 | <dependency> | 41 | <dependency> |
| 42 | <groupId>org.springdoc</groupId> | 42 | <groupId>org.springdoc</groupId> |
| 43 | - <artifactId>springdoc-openapi-javadoc</artifactId> | 43 | + <artifactId>springdoc-openapi-ui</artifactId> |
| 44 | </dependency> | 44 | </dependency> |
| 45 | 45 | ||
| 46 | <dependency> | 46 | <dependency> |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
| 1 | package cn.iocoder.yudao.framework.swagger.config; | 1 | package cn.iocoder.yudao.framework.swagger.config; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.models.Components; | 3 | import io.swagger.v3.oas.models.Components; |
| 4 | -import io.swagger.v3.oas.models.ExternalDocumentation; | ||
| 5 | import io.swagger.v3.oas.models.OpenAPI; | 4 | import io.swagger.v3.oas.models.OpenAPI; |
| 6 | import io.swagger.v3.oas.models.info.Info; | 5 | import io.swagger.v3.oas.models.info.Info; |
| 7 | import io.swagger.v3.oas.models.info.License; | 6 | import io.swagger.v3.oas.models.info.License; |
| @@ -15,6 +14,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties | @@ -15,6 +14,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties | ||
| 15 | import org.springframework.context.annotation.Bean; | 14 | import org.springframework.context.annotation.Bean; |
| 16 | import org.springframework.http.HttpHeaders; | 15 | import org.springframework.http.HttpHeaders; |
| 17 | 16 | ||
| 17 | +import java.util.Arrays; | ||
| 18 | + | ||
| 18 | /** | 19 | /** |
| 19 | * Swagger3 自动配置类 | 20 | * Swagger3 自动配置类 |
| 20 | * | 21 | * |
| @@ -29,15 +30,30 @@ public class YudaoSwaggerAutoConfiguration { | @@ -29,15 +30,30 @@ public class YudaoSwaggerAutoConfiguration { | ||
| 29 | 30 | ||
| 30 | @Bean | 31 | @Bean |
| 31 | public OpenAPI createRestApi(SwaggerProperties properties) { | 32 | public OpenAPI createRestApi(SwaggerProperties properties) { |
| 32 | - return new OpenAPI() | ||
| 33 | - .info(new Info().title(properties.getTitle()) | ||
| 34 | - .description(properties.getDescription()) | ||
| 35 | - .version(properties.getVersion()) | ||
| 36 | - .license(new License().name("MIT").url("https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE"))) | ||
| 37 | - .externalDocs(new ExternalDocumentation() | ||
| 38 | - .description(properties.getDescription()) | ||
| 39 | - .url("https://gitee.com/zhijiantianya/ruoyi-vue-pro")); | 33 | + //信息 |
| 34 | + Info info = new Info() | ||
| 35 | + .title(properties.getTitle()) | ||
| 36 | + .description(properties.getDescription()) | ||
| 37 | + .version(properties.getVersion()) | ||
| 38 | + .license(new License().name("MIT").url("https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE")); | ||
| 39 | + //鉴权组件(随便起名的) | ||
| 40 | + SecurityScheme securityScheme = new SecurityScheme() | ||
| 41 | + .type(SecurityScheme.Type.OAUTH2) | ||
| 42 | + .scheme("bearer")//固定写法 | ||
| 43 | + .bearerFormat("JWT") | ||
| 44 | + .in(SecurityScheme.In.HEADER) | ||
| 45 | + .name(HttpHeaders.AUTHORIZATION); | ||
| 46 | + Components components = new Components() | ||
| 47 | + .addSecuritySchemes("bearer", securityScheme); | ||
| 48 | + | ||
| 49 | + //鉴权限制要求(随便起名的) | ||
| 50 | + SecurityRequirement securityRequirement = new SecurityRequirement() | ||
| 51 | + .addList("bearer", Arrays.asList("read", "write")); | ||
| 40 | 52 | ||
| 53 | + return new OpenAPI() | ||
| 54 | + .info(info) | ||
| 55 | + .components(components) | ||
| 56 | + .addSecurityItem(securityRequirement); | ||
| 41 | } | 57 | } |
| 42 | 58 | ||
| 43 | @Bean | 59 | @Bean |
| @@ -56,5 +72,4 @@ public class YudaoSwaggerAutoConfiguration { | @@ -56,5 +72,4 @@ public class YudaoSwaggerAutoConfiguration { | ||
| 56 | .build(); | 72 | .build(); |
| 57 | } | 73 | } |
| 58 | 74 | ||
| 59 | - | ||
| 60 | } | 75 | } |