Unverified Commit 951cb6b1 authored by Kerwin's avatar Kerwin Committed by GitHub

[Feature] Add swagger api doc (#954)

* Add swagger api doc

* update datasource config info in the application file
parent b3ad0a5f
...@@ -42,6 +42,10 @@ ...@@ -42,6 +42,10 @@
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
package com.dlink.configure;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Knife4jConfiguration {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("V1.0")
.select()
.apis(RequestHandlerSelectors.basePackage("com.dlink.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Dlink REST APIS")
.description("Dlink REST APIS")
.version("1.0")
.build();
}
}
...@@ -6,6 +6,9 @@ spring: ...@@ -6,6 +6,9 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
application: application:
name: dlink name: dlink
mvc:
pathmatch:
matching-strategy: ant_path_matcher
main: main:
allow-circular-references: true allow-circular-references: true
# flyway: # flyway:
...@@ -62,4 +65,7 @@ sa-token: ...@@ -62,4 +65,7 @@ sa-token:
# token风格 # token风格
token-style: uuid token-style: uuid
# 是否输出操作日志 # 是否输出操作日志
is-log: false is-log: false
\ No newline at end of file
knife4j:
enable: true
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
<javax.mail>1.6.2</javax.mail> <javax.mail>1.6.2</javax.mail>
<poi.version>4.1.2</poi.version> <poi.version>4.1.2</poi.version>
<commons-email>1.5</commons-email> <commons-email>1.5</commons-email>
<knife4j.version>3.0.3</knife4j.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -122,6 +123,11 @@ ...@@ -122,6 +123,11 @@
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment