Commit 2cbe1a11 by fsn

修改swagger扫描方式为注解扫描

parent bc644448
package com.stylefeng.guns.config;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -27,14 +28,15 @@ public class SwaggerConfig{
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.stylefeng.guns.modular.system.controller"))
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) //这里采用包含注解的方式来确定要显示的接口
//.apis(RequestHandlerSelectors.basePackage("com.stylefeng.guns.modular.system.controller")) //这里采用包扫描的方式来确定要显示的接口
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Guns RESTful APIs")
.title("Guns Doc")
.description("Guns Api文档")
.termsOfServiceUrl("http://git.oschina.net/naan1993/guns")
.contact("stylefeng")
......
......@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
......@@ -43,7 +44,7 @@ public class CodeController extends BaseController {
@ApiImplicitParam(name = "bizEnName", value = "业务英文名称", required = true, dataType = "String"),
@ApiImplicitParam(name = "path", value = "项目生成类路径", required = true, dataType = "String")
})
@RequestMapping(value = "/generate")
@RequestMapping(value = "/generate",method = RequestMethod.POST)
@ResponseBody
public Object add(String bizChName, String bizEnName, String path) {
if (ToolUtil.isOneEmpty(bizChName, bizEnName)) {
......
......@@ -4,7 +4,7 @@
################### guns配置 ###################
guns:
swagger-open: false #是否开启swagger (true/false)
swagger-open: true #是否开启swagger (true/false)
kaptcha-open: false #是否开启登录时验证码 (true/false)
#file-upload-path: d:/tmp #文件上传目录(不配置的话为java.io.tmpdir目录)
......
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