优化Swagger2,增加测试类

master
yangzhengze 6 years ago committed by Limy
parent 4adab78e2e
commit 7d71b0aafd

@ -1,5 +1,6 @@
package com.ruoyi.framework.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
@ -17,24 +18,35 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
/** 系统基础配置*/
@Autowired
private RuoYiConfig ruoYiConfig;
/**
* API
* @return
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
//详细定制
.apiInfo(apiInfo())
.select()
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.*.*.controller"))
//扫描所有
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
.title("系统接口列表")
.description("API接口测试平台\",\n" +
" \"提供后台所有Restful接口\",")
.termsOfServiceUrl("http://localhost/swagger-ui.html")
.contact(new Contact("RuoYi", "https://gitee.com/y_project/RuoYi", "1403014932@qq.com"))
.contact(new Contact(ruoYiConfig.getName(), "https://gitee.com/y_project/RuoYi", "1403014932@qq.com"))
.version("1.1.0")
.build();
}

@ -0,0 +1,18 @@
package com.ruoyi;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
*
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class RuoYiApplicationTests {
@Test
public void contextLoads() {
}
}
Loading…
Cancel
Save