docs(0): [java]-[wcferry-mvn]-集成swagger3文档,便于后期接口展示

This commit is contained in:
chandler 2024-09-24 22:22:09 +08:00
parent 19bcd7d3ed
commit 538e9232f5
4 changed files with 61 additions and 0 deletions

View File

@ -55,6 +55,8 @@ wcferry:
启动后springboot自身的端口为 9201 socket的端口为 10086 启动后springboot自身的端口为 9201 socket的端口为 10086
swagger地址http://localhost:9201/swagger-ui/index.html
## 参与开发 ## 参与开发
### 核心依赖 ### 核心依赖

View File

@ -25,6 +25,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 日志 --> <!-- 日志 -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@ -37,6 +42,12 @@
<version>1.18.30</version> <version>1.18.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- swagger3包-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>

View File

@ -0,0 +1,44 @@
package com.iamteer.config;
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.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
/**
* 配置类-swagger
* http://localhost:9201/swagger-ui/index.html
*
* @author chandler
* @date 2024-09-24 22:13
*/
@EnableOpenApi
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select()
// 替换为您的Controller所在的包路径
.apis(RequestHandlerSelectors.basePackage("com.iamteer.controller"))
// 地址
.paths(PathSelectors.any()).build().apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 文档标题
.title("Wcferry接口文档")
// 文档路径
.description("微信机器人底层框架接口文档")
// 文档版本
.version("1.0.0").build();
}
}

View File

@ -10,6 +10,10 @@ spring:
application: application:
# 应用名 # 应用名
name: wcferry-mvn name: wcferry-mvn
# swagger适配
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# 本服务参数 # 本服务参数
wcferry: wcferry: