mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 03:01:53 +08:00
refactor: springdoc 替换 springfox
This commit is contained in:
parent
9fc6e0f00b
commit
88ce5e540e
@ -165,7 +165,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-javadoc</artifactId>
|
<artifactId>springdoc-openapi-ui</artifactId>
|
||||||
<version>${springdoc.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -63,11 +63,6 @@
|
|||||||
<artifactId>springdoc-openapi-webmvc-core</artifactId>
|
<artifactId>springdoc-openapi-webmvc-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-javadoc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 监控相关 -->
|
<!-- 监控相关 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.skywalking</groupId>
|
<groupId>org.apache.skywalking</groupId>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-javadoc</artifactId>
|
<artifactId>springdoc-openapi-ui</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.framework.swagger.config;
|
package cn.iocoder.yudao.framework.swagger.config;
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.Components;
|
import io.swagger.v3.oas.models.Components;
|
||||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import io.swagger.v3.oas.models.info.License;
|
import io.swagger.v3.oas.models.info.License;
|
||||||
@ -15,6 +14,8 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger3 自动配置类
|
* Swagger3 自动配置类
|
||||||
*
|
*
|
||||||
@ -29,15 +30,30 @@ public class YudaoSwaggerAutoConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI createRestApi(SwaggerProperties properties) {
|
public OpenAPI createRestApi(SwaggerProperties properties) {
|
||||||
return new OpenAPI()
|
//信息
|
||||||
.info(new Info().title(properties.getTitle())
|
Info info = new Info()
|
||||||
|
.title(properties.getTitle())
|
||||||
.description(properties.getDescription())
|
.description(properties.getDescription())
|
||||||
.version(properties.getVersion())
|
.version(properties.getVersion())
|
||||||
.license(new License().name("MIT").url("https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE")))
|
.license(new License().name("MIT").url("https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE"));
|
||||||
.externalDocs(new ExternalDocumentation()
|
//鉴权组件(随便起名的)
|
||||||
.description(properties.getDescription())
|
SecurityScheme securityScheme = new SecurityScheme()
|
||||||
.url("https://gitee.com/zhijiantianya/ruoyi-vue-pro"));
|
.type(SecurityScheme.Type.OAUTH2)
|
||||||
|
.scheme("bearer")//固定写法
|
||||||
|
.bearerFormat("JWT")
|
||||||
|
.in(SecurityScheme.In.HEADER)
|
||||||
|
.name(HttpHeaders.AUTHORIZATION);
|
||||||
|
Components components = new Components()
|
||||||
|
.addSecuritySchemes("bearer", securityScheme);
|
||||||
|
|
||||||
|
//鉴权限制要求(随便起名的)
|
||||||
|
SecurityRequirement securityRequirement = new SecurityRequirement()
|
||||||
|
.addList("bearer", Arrays.asList("read", "write"));
|
||||||
|
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(info)
|
||||||
|
.components(components)
|
||||||
|
.addSecurityItem(securityRequirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -56,5 +72,4 @@ public class YudaoSwaggerAutoConfiguration {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user