2014-11-05 146 views
0

功能,當我試圖配置家居招搖,它的工作..不知何故部分,它從資源忽略的功能和只考慮類@Api adnotation揚鞭忽略資源

我使用Apache CXF +彈簧

生成JSON只包含類的描述,這裏

..."apis":[{"path":"/","description":"Entities operations"}]... 

沒有方法的控制器adnotations

@Path("/") 
@Api(value = "/", description = "Entities operations") 
@Controller 
public class RepositoryResource 
.... 

功能adnotation

@GET 
@ApiOperation(value = "Method to check if this resources is up and running") 
public String hello() 
... 

日誌消息spoted

Could not find a definition for bean with id {http://listing.jaxrs.swagger.wordnik.com/}ApiListingResourceJSON.http-destination 

spring配置

<jaxrs:server id="restAPI" address="/" staticSubresourceResolution="true"> 
    <jaxrs:serviceBeans> 
     <ref bean="swaggerResourceJSON"/> 
     <ref bean="repositoryResource"/> 
    </jaxrs:serviceBeans> 
.... 

回答

0

不要爲你的@Api值使用的根( 「/」) - 這將打破文件。即使你有@Path("/"),你應該有類似@Api("/root")

這不會影響API本身,只有在提供文檔的位置。

一旦你作出這樣的修改,您/ API的文檔看起來像:

..."apis":[{"path":"/root","description":"Entities operations"}]...

而這資源是可在/ API-DOCS /根。用swagger-ui運行它將產生適當的API調用。