如何Swagger注释嵌套的REST资源?

时间:2017-05-25 13:03:37

标签: java jersey swagger

我使用swagger 1.3.0和Jersey 1.x.我正在尝试为我的资源方法添加swagger文档,如下所示:

@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文档。感谢您提前获得帮助:)

1 个答案:

答案 0 :(得分:0)

我终于通过注释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(){}

}
相关问题