2017-05-25 54 views
0

我在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文檔。感謝您的幫助提前:)

+0

您是否嘗試過用相同註釋父類註釋嵌套類? –

+0

是的,我得到它的工作。不過謝謝 – Praveen

回答

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(){} 

}