build: swagger
This commit is contained in:
41
pom.xml
41
pom.xml
@@ -8,6 +8,12 @@
|
||||
<artifactId>metis</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.3.4</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
@@ -91,6 +97,16 @@
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -99,7 +115,6 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>3.3.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -107,7 +122,18 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 编译插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
<!-- 注解静态编译功能 注:仅支持 maven-compiler-plugin 的 version 在3.6.0 以上才生效 -->
|
||||
<annotationProcessorPaths>
|
||||
<!-- 必须配置 lombok 的注解编译,否则会因为配置了(mapstruct-processor)启动了导致 lombok 对内部类的静态编译失效 -->
|
||||
@@ -129,19 +155,6 @@
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 编译插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
31
src/main/java/com/metis/config/SwaggerConfig.java
Normal file
31
src/main/java/com/metis/config/SwaggerConfig.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.metis.config;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public OpenAPI customOpenAPI() {
|
||||
Contact contact = new Contact();
|
||||
contact.setEmail("wlddhj@163.com");
|
||||
contact.setName("huangjian");
|
||||
contact.setUrl("http://doc.xiaominfo.com");
|
||||
return new OpenAPI()
|
||||
// 增加swagger授权请求头配置
|
||||
// .components(new Components().addSecuritySchemes(CommonConstant.X_ACCESS_TOKEN,
|
||||
// new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme(CommonConstant.X_ACCESS_TOKEN)))
|
||||
.info(new Info()
|
||||
.title("Shi9 后台服务API接口文档")
|
||||
.version("1.0")
|
||||
.contact(contact)
|
||||
.description("Knife4j集成springdoc-openapi示例")
|
||||
.termsOfService("http://doc.xiaominfo.com")
|
||||
.license(new License().name("Apache 2.0")
|
||||
.url("http://www.apache.org/licenses/LICENSE-2.0.html")));
|
||||
}
|
||||
}
|
||||
@@ -29,3 +29,29 @@ mybatis-plus:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
tags-sorter: alpha
|
||||
group-configs:
|
||||
- group: bis
|
||||
display-name: "业务接口文档"
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: org.shi9.module.bis
|
||||
- group: system
|
||||
display-name: "业务接口文档"
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: com.metis.controller
|
||||
default-flat-param-object: true
|
||||
knife4j:
|
||||
# 开启增强配置
|
||||
enable: true
|
||||
# 开启生产环境屏蔽(如果是生产环境,需要把下面配置设置true)
|
||||
# production: true
|
||||
setting:
|
||||
language: zh_cn
|
||||
swagger-model-name: 实体类列表
|
||||
basic: # 开始授权认证
|
||||
enable: true
|
||||
username: admin
|
||||
password: 123456
|
||||
|
||||
Reference in New Issue
Block a user