{
schemaValidationMessages: [
{
level: "error",
message: "Can't read from file ./swagger.json"
}
]
}
25 回复
@wendal 就是您给的demo
2018-01-03 16:34:08,880 [http-nio-8081-exec-5] DEBUG org.nutz.mvc.impl.UrlMappingImpl - Search mapping for [GET] path=/swagger/index : NOT Action match
2018-01-03 16:34:09,229 [http-nio-8081-exec-3] DEBUG org.nutz.mvc.impl.UrlMappingImpl - Found mapping for [GET] path=/swagger/swagger : SwaggerModule.swagger(SwaggerModule.java:30)
2018-01-03 16:34:09,229 [http-nio-8081-exec-3] DEBUG org.nutz.ioc.impl.NutIoc - Get 'swaggerModule'<class com.hefupb.hegui.modules.SwaggerModule>
package com.hefupb.hegui.modules;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.*;
@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;
}
}
2018-01-03 16:50:02,401 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.ioc.loader.annotation.AnnotationIocLoader - Found @IocBean : class com.hefupb.hegui.modules.SwaggerDemoModule
2018-01-03 16:50:02,411 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.ioc.loader.annotation.AnnotationIocLoader - Found @IocBean : class com.hefupb.hegui.modules.SwaggerModule
@wendal 启动日志是有SwaggerModule的
2018-01-03 16:50:02,488 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.mvc.impl.Loadings - >> add 'com.hefupb.hegui.modules.SwaggerDemoModule'
2018-01-03 16:50:02,488 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.mvc.impl.Loadings - >> add 'com.hefupb.hegui.modules.SwaggerModule'
2018-01-03 16:50:02,589 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.mvc.impl.UrlMappingImpl - '/demo/echo' >> (SwaggerDemoModule.java:30).echo : String | @Ok(raw ) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
2018-01-03 16:50:02,590 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.mvc.impl.UrlMappingImpl - '/demo/ping' >> (SwaggerDemoModule.java:21).ping : Object | @Ok(json:full) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
2018-01-03 16:50:02,592 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.nutz.mvc.impl.UrlMappingImpl - '/swagger/swagger' >> (SwaggerModule.java:30).swagger : void
@wendal 我映射的action是正常的,就是http://localhost:8081/swagger/ 没有我的接口api
@wendal 这个package的的位置有规定吗?
@wendal 好的我试一下
@wendal 还是不行
//项目目录
--com.hefupb.hegui
--modules
-NutReaderExtension.java
-SwaggerDemoModule.java
-SwaggerModule.java
||
// 扫描package路径:
for (Class<?> klass : Scans.me().scanPackage("com.hefupb.hegui.common.modules")) {
注意看SwaggerDemoModule, 它的package声明是 "package com.hefupb.hegui.modules;"
所以应该写 ""com.hefupb.hegui", 这样就万无一失啦
@wendal 谢谢!
添加回复
请先登陆