2012-10-31 90 views
0

Martin,我一直試圖使用您的wadl文檔生成代碼來記錄來自Javadoc註釋的REST接口,並且我一直無法獲取它來記錄參數方法/查詢參數。我不太確定我做錯了什麼。我以通常的方式向該方法提供Javadoc評論,例如:如何獲取WADL生成的文檔中的參數描述

/** 
* Gets an Account object by id. 
* @param req the HttpServletRequest encapsulating this GET request 
* @param q the id of the Account object to be returned 
* @param xid optional transaction id associated with this request 
* @return an AccountModel object corresponding to the requested it. 
* If not found an APIException is thrown. 
*/ 
@GET @Path("/id") 
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) 
public AccountModel getAsXML_JSON(@Context final HttpServletRequest req, 
     @QueryParam("q") String q, 
     @QueryParam("xid") String xid) 

我確定有些事情顯而易見,我錯過了。如上所述,註釋「通過ID獲取帳戶對象」使其成爲resourcedoc.xml文件,並從那裏到application.wadl文件,但沒有任何參數定義可用。 當我添加

* @annotationDoc {@name q} {@doc the id of the Account object to be returned} 
* @annotationDoc {@name xid} {@doc optional transaction id associated with this request} 

我可以看到在resourcedoc.xml文件中的參數的描述,但它看起來像他們在錯誤的地方正在出現,並沒有在application.wadl文件顯示出來。 你可以給任何幫助將不勝感激。

回答

0

只是回答我自己的問題,問題是resourcedoclet無法找到QueryParam或Context類的定義。因此它將QueryParam插入到生成的XML中,但沒有包含標識QueryParam引用的參數的名稱/值對。這導致生成的html包含方法描述,但不包含參數描述,因爲QueryParam引用的參數無法找到。 此修復程序只是將jsr311-api-1.1.1.jar包含在調用resourcdoclet的Javadoc命令的類路徑中。

0

添加

<dependency> 
    <groupId>javax.ws.rs</groupId> 
    <artifactId>javax.ws.rs-api</artifactId> 
    <version>2.0</version> 
</dependency> 

到你的pom.xml