mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: Swagger API version keep up-to-date with POM version
This commit is contained in:
commit
85b8d004e4
@ -214,6 +214,7 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
|
||||
</goals>
|
||||
</execution>
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.github.kfcfans.powerjob.server.common.config;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.info.BuildProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
@ -11,26 +14,40 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import static springfox.documentation.builders.PathSelectors.any;
|
||||
|
||||
/**
|
||||
* Swagger UI 配置
|
||||
* Configuration class for Swagger UI.
|
||||
*
|
||||
* @author tjq
|
||||
* @author Jiang Jining
|
||||
* @since 2020/3/29
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
|
||||
|
||||
private final BuildProperties buildProperties;
|
||||
|
||||
public SwaggerConfig(@Autowired(required = false) final BuildProperties buildProperties) {
|
||||
this.buildProperties = buildProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
String version = "Unknown";
|
||||
if (buildProperties != null) {
|
||||
String pomVersion = buildProperties.getVersion();
|
||||
if (StringUtils.isNotBlank(pomVersion)) {
|
||||
version = pomVersion;
|
||||
}
|
||||
}
|
||||
// apiInfo()用来创建该Api的基本信息(这些基本信息会展现在文档页面中
|
||||
ApiInfo apiInfo = new ApiInfoBuilder()
|
||||
.title("PowerJob")
|
||||
.description("Distributed scheduling and computing framework.")
|
||||
.license("Apache Licence 2")
|
||||
.termsOfServiceUrl("https://github.com/KFCFans/PowerJob")
|
||||
.version("3.3.3")
|
||||
.version(version)
|
||||
.build();
|
||||
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo)
|
||||
// select()函数返回一个ApiSelectorBuilder实例
|
||||
@ -39,5 +56,5 @@ public class SwaggerConfig {
|
||||
.paths(any())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user