2015-04-07 46 views
6

我試圖整合與駱駝項目如何在我的應用招搖的UI集成

招搖下面這個例子https://github.com/apache/camel/tree/master/examples/camel-example-servlet-rest-tomcat

我如何使用這個例子項目訪問招搖的用戶界面?

我在tomcat中刪除了war文件。

和訪問http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs我得到這個...

{ 「apiVersion」: 「1.2.3」, 「swaggerVersion」: 「1.2」, 「蜜蜂」:[{ 「路徑」: 「/用戶」 ,「description」:「用戶休息服務」}],「info」:{「title」:「用戶服務」,「描述」:「駱駝休息示例與提供用戶REST服務的Swagger」}}

但我的問題是 - 我如何訪問swagger-ui/index.html?

訪問swagger-UI的確切URL是什麼?

回答

7

您必須將swagger-ui的dist文件夾的內容複製到項目的webapp文件夾中。

index.html中,

window.swaggerUi = new SwaggerUi({ 
    url: "http://petstore.swagger.wordnik.com/api/api-docs", 
    dom_id: "swagger-ui-container", 

必須用本

http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs 

替換URL詳情,請點擊此鏈接整合招搖的UI。

https://github.com/swagger-api/swagger-ui

+0

我複製了dist的內容,但仍然無法訪問UI ... URL應該是什麼? http:// localhost:8080/social /也不是http:// localhost:8080/social/index.html正在爲我工​​作(我的資源上下文是「社交」)。 –

+0

@ hick209,父母建議將文件添加到'webapp/WEB-INF'中,但我猜會讓他們無法訪問,是不是?你有沒有試圖直接將它們添加到'webapp'? – arcuri82

1

http://localhost:8080/camel-example-servlet-rest-tomcat/ {}基本路徑/dist/index.html,如果複製DIST的文件夾是。如果您已重命名dist文件夾,請使用新名稱而不是dist。將basepath替換爲您在web.xml中配置的basepath。該代碼段看起來是這樣的:

<init-param> 
<param-name>swagger.api.basepath</param-name> 
<param-value>/rest</param-value> 
</init-param> 
0

這些都是你揚鞭文檔:

{"apiVersion":"1.2.3","swaggerVersion":"1.2","apis":[{"path"... 

現在你需要揚鞭的用戶界面,以消耗他們。您可以在任何地方安裝。將Swagger-UI放入您的項目中並不難。您只需編輯index.html文件以指向您的文檔路徑(上面的JSON輸出)。