Swagger api自动生成
swagger使用
注意,这里一定要放在resource的 目录,因为以上的配置中是jboot.swagger.path=/swaggerui
,当然可以通过这个配置来修改这个存放目录。
代码如下:
@RequestMapping("/swaggerTest")
@Api(description = "用户相关接口文档", basePath = "/swaggerTest", tags = "abc")
@ApiOperation(value = "用户列表", httpMethod = "GET", notes = "user list")
public void index() {
}
@ApiOperation(value = "添加用户", httpMethod = "POST", notes = "add user")
@ApiImplicitParam(name = "username", value = "用户名", paramType = "form", dataType = "string", required = true),
@ApiImplicitParam(name = "k1", value = "k1", paramType = "form", dataType = "string", required = true),
})
renderJson(Ret.ok("k1", "v1").set("username", username));
}
图片1
在图片2中,我们可以输入参数,并点击 Execute
按钮进行测试。