Commit 88ce5e540e06f3f49383ba0fd93936e55654ad45

Authored by xingyu4j
1 parent 9fc6e0f0

refactor: springdoc 替换 springfox

yudao-dependencies/pom.xml
... ... @@ -165,7 +165,7 @@
165 165  
166 166 <dependency>
167 167 <groupId>org.springdoc</groupId>
168   - <artifactId>springdoc-openapi-javadoc</artifactId>
  168 + <artifactId>springdoc-openapi-ui</artifactId>
169 169 <version>${springdoc.version}</version>
170 170 </dependency>
171 171  
... ...
yudao-framework/yudao-common/pom.xml
... ... @@ -63,11 +63,6 @@
63 63 <artifactId>springdoc-openapi-webmvc-core</artifactId>
64 64 </dependency>
65 65  
66   - <dependency>
67   - <groupId>org.springdoc</groupId>
68   - <artifactId>springdoc-openapi-javadoc</artifactId>
69   - </dependency>
70   -
71 66 <!-- 监控相关 -->
72 67 <dependency>
73 68 <groupId>org.apache.skywalking</groupId>
... ...
yudao-framework/yudao-spring-boot-starter-web/pom.xml
... ... @@ -40,7 +40,7 @@
40 40  
41 41 <dependency>
42 42 <groupId>org.springdoc</groupId>
43   - <artifactId>springdoc-openapi-javadoc</artifactId>
  43 + <artifactId>springdoc-openapi-ui</artifactId>
44 44 </dependency>
45 45  
46 46 <dependency>
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
1 1 package cn.iocoder.yudao.framework.swagger.config;
2 2  
3 3 import io.swagger.v3.oas.models.Components;
4   -import io.swagger.v3.oas.models.ExternalDocumentation;
5 4 import io.swagger.v3.oas.models.OpenAPI;
6 5 import io.swagger.v3.oas.models.info.Info;
7 6 import io.swagger.v3.oas.models.info.License;
... ... @@ -15,6 +14,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
15 14 import org.springframework.context.annotation.Bean;
16 15 import org.springframework.http.HttpHeaders;
17 16  
  17 +import java.util.Arrays;
  18 +
18 19 /**
19 20 * Swagger3 自动配置类
20 21 *
... ... @@ -29,15 +30,30 @@ public class YudaoSwaggerAutoConfiguration {
29 30  
30 31 @Bean
31 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 59 @Bean
... ... @@ -56,5 +72,4 @@ public class YudaoSwaggerAutoConfiguration {
56 72 .build();
57 73 }
58 74  
59   -
60 75 }
... ...