mirror of https://gitee.com/xiaonuobase/snowy
【升级】swagger升级版本至2.0.8,加入分组demo(默认注释)
parent
159ab99ee7
commit
2514612c33
19
pom.xml
19
pom.xml
|
@ -37,8 +37,6 @@
|
|||
<jwt.version>0.9.1</jwt.version>
|
||||
<hutool.version>5.5.8</hutool.version>
|
||||
<lombok.versin>1.18.12</lombok.versin>
|
||||
<swagger.version>2.9.2</swagger.version>
|
||||
<swagger.bootstrap.ui.version>1.9.6</swagger.bootstrap.ui.version>
|
||||
<easypoi.version>4.2.0</easypoi.version>
|
||||
<jodconverter.version>4.2.0</jodconverter.version>
|
||||
<libreoffice.version>6.4.3</libreoffice.version>
|
||||
|
@ -48,6 +46,7 @@
|
|||
<aliyun.sms.sdk.version>4.4.6</aliyun.sms.sdk.version>
|
||||
<aliyun.sms.esc.version>4.17.6</aliyun.sms.esc.version>
|
||||
<qcloud.sms.sdk.version>3.1.57</qcloud.sms.sdk.version>
|
||||
<knife4j.version>2.0.8</knife4j.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -124,21 +123,11 @@
|
|||
<version>${lombok.versin}</version>
|
||||
</dependency>
|
||||
|
||||
<!--swagger接口文档-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<!-- swagger接口文档 -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>${swagger.bootstrap.ui.version}</version>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--easypoi导入导出-->
|
||||
|
|
|
@ -71,17 +71,9 @@
|
|||
</dependency>
|
||||
|
||||
<!--swagger接口文档-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--验证码-->
|
||||
|
|
|
@ -25,9 +25,6 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
|||
package vip.xiaonuo.sys.config;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import vip.xiaonuo.core.consts.CommonConstant;
|
||||
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
|
@ -40,7 +37,8 @@ import springfox.documentation.service.Contact;
|
|||
import springfox.documentation.service.Parameter;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||
import vip.xiaonuo.core.consts.CommonConstant;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -48,15 +46,18 @@ import java.util.List;
|
|||
* swagger配置
|
||||
*
|
||||
* @author xuyuxiang
|
||||
* @date 2020/3/11 15:05
|
||||
*/
|
||||
* 加入分组功能(默认注释掉)
|
||||
* <p>
|
||||
* https://doc.xiaominfo.com/knife4j/changelog/2017-12-18-swagger-bootstrap-ui-1.7-issue.html
|
||||
* </p>
|
||||
* @author ldw4033#163.com
|
||||
* @date 2021/4/9 10:42
|
||||
**/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableSwaggerBootstrapUI
|
||||
@EnableSwagger2WebMvc
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
private List<Parameter> getParameters() {
|
||||
Parameter parameter = new ParameterBuilder()
|
||||
.name("Authorization")
|
||||
.description("token令牌")
|
||||
|
@ -67,9 +68,15 @@ public class SwaggerConfig {
|
|||
|
||||
List<Parameter> parameters = CollectionUtil.newArrayList();
|
||||
parameters.add(parameter);
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket defaultApi() {
|
||||
List<Parameter> parameters = getParameters();
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.apiInfo(defaultApiInfo())
|
||||
.groupName("默认接口")
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage(CommonConstant.DEFAULT_PACKAGE_NAME))
|
||||
.paths(PathSelectors.any())
|
||||
|
@ -77,7 +84,7 @@ public class SwaggerConfig {
|
|||
.globalOperationParameters(parameters);
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
private ApiInfo defaultApiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Snowy Doc")
|
||||
.description("Snowy Doc文档")
|
||||
|
@ -87,4 +94,31 @@ public class SwaggerConfig {
|
|||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 想分组请放开注释
|
||||
*/
|
||||
|
||||
// @Bean
|
||||
// public Docket groupRestApi() {
|
||||
// List<Parameter> parameters = getParameters();
|
||||
// return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .apiInfo(groupApiInfo())
|
||||
// .groupName("自定义")
|
||||
// .select()
|
||||
// //TODO 这里改为自己的包名
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.example.XXX"))
|
||||
// .paths(PathSelectors.any())
|
||||
// .build()
|
||||
// .globalOperationParameters(parameters);
|
||||
// }
|
||||
//
|
||||
// private ApiInfo groupApiInfo() {
|
||||
// return new ApiInfoBuilder()
|
||||
// .title("自定义")
|
||||
// .description("自定义API")
|
||||
// .termsOfServiceUrl("http://www.example.com/")
|
||||
// .version("1.0")
|
||||
// .build();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/snowy-pub?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/snowy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
redis:
|
||||
|
|
Loading…
Reference in New Issue