如何Swagger注释嵌套的REST资源?
问题描述:
我在Jersey 1.x上使用了Swagger 1.3.0。我想为我的资源方法添加招摇文件如下:如何Swagger注释嵌套的REST资源?
@Api(.....)
class RootResource{
@GET
@Path("/")
@ApiOperation(....)
@ApiResponse(....)
public Response get(){} // i am able to get this method's swagger doc
@Path("/nestedResource")
public NestedResource getNestedResource(){
return new NestedResource();
}
}
class NestedResource{
@GET
@ApiOperation(....)
@ApiResponse(....)
public Response getNestedResource(){} // i am NOT able to get this method's swagger doc
}
请理解上面的代码只是一个模板,而不是一个完整的工作版本。
请让我知道如何为嵌套资源添加swagger文档。感谢您的帮助提前:)
答
我终于得到它通过注释的NestedResource像下面的工作:
/* Yes,i left the value attribute as blank so that path will be constructed
as "/NestedResource" */
@Api(basePath="/",value="")
class NestedResource{
@GET
@ApiOperation(....)
@ApiResponse(....)
public Response getNestedResource(){}
}
您是否尝试过用相同注释父类注释嵌套类? –
是的,我得到它的工作。不过谢谢 – Praveen