Commit d99ad5d9 authored by taabe's avatar taabe

使用tyboot框架自带swagger 配置

parent 35e8ee06
package org.amos.boot.biz.common.configs;
import io.swagger.annotations.ApiOperation;
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.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* swagger配置类 模块如果需要引入则引入
*
* @author DELL
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("服务接口")
.enable(true)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.apis(RequestHandlerSelectors.basePackage("org.amos.boot"))
.paths(PathSelectors.any())
.build();
}
/**
* 构建 api文档的详细信息函数,注意这里的注解引用的是哪个
*/
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("RestFul API")
//创建人
.contact(new Contact("amos", "", ""))
//版本号
.version("1.0")
//描述
.description("API 描述")
.build();
}
}
\ No newline at end of file
...@@ -6,6 +6,8 @@ import org.amos.boot.biz.common.utils.CommonResponseUtil; ...@@ -6,6 +6,8 @@ import org.amos.boot.biz.common.utils.CommonResponseUtil;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
/** /**
...@@ -17,6 +19,7 @@ public class TestController extends BaseController { ...@@ -17,6 +19,7 @@ public class TestController extends BaseController {
@ApiOperation(value = "测试接口") @ApiOperation(value = "测试接口")
@GetMapping(value = "/testGet") @GetMapping(value = "/testGet")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
public ResponseModel test() { public ResponseModel test() {
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
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