2012-10-31 52 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