看nutz-integration-swagger的readme并没有看到用了nutz-integration-swagger插件啊
7 回复
public void init() {
log.info("init swagger ...");
swagger = new Swagger();
Info info = new Info();
info.title("ABC....");
swagger.info(info);
HashSet<Class<?>> classes = new HashSet<>();
// 把下来的package路径改成你自己的package路径
for (Class<?> klass : Scans.me().scanPackage("com.tiankong.action")) {
classes.add(klass);
}
Reader.read(swagger, classes);
System.out.println("hehe"+JSON.toJSON(swagger));
}
@IocBean
@At("/user")
@Api(value = "swagger")
public class UserAction {
@At("/login")
@Ok("json")
@ApiOperation(value = "登陆", notes = "登陆")
@ApiImplicitParams({
@ApiImplicitParam(name = "loginType",value = "登录类型",dataType="integer", required = true, paramType = "query"),
@ApiImplicitParam(name = "code",value = "验证码",dataType="integer", required = false, paramType = "query")
})
public Result login(@Param("..")AppUser user,@Param("loginType")int loginType,@Param("code")int code) {
}
hehe{"swagger":"2.0","info":{"vendorExtensions":{},"title":"ABC...."}}
为啥swagger 对象什么都没有呢、
@wendal 我自己打印的时候添加的。。
来,这个是可用的,你放进去测试一下
@Api(value = "demo")
@IocBean
@At("/demo")
public class SwaggerDemoModule {
@GET
@ApiOperation(value = "心跳接口", notes = "发我一个ping,回你一个pong", httpMethod="GET")
@At
@Ok("json:full")
public Object ping() {
return new NutMap("ok", true).setv("data", "pong");
}
@POST
@ApiOperation(value = "回显接口", notes = "发我一个字符串,原样回复一个字符串", httpMethod="POST")
@ApiImplicitParams({@ApiImplicitParam(name = "text", paramType="form", value = "想发啥就发啥", dataType="string", required = true)})
@At
@Ok("raw")
public String echo(@Param("text") String text) {
return text;
}
}
@wendal 经过我的百般尝试发现@ApiOperation的属性httpMethod是必带的。。。
添加回复
请先登陆