2012-07-11 34 views
6

我正在用Swagger來記錄REST Web API。我已經下載了petstore示例。它由一個引用resources.jsonpet.jsonuser.jsonSwagger用戶界面錯誤:無法獲取API列表

{ 
    "apiVersion":"0.2", 
    "swaggerVersion":"1.0", 
    "basePath":"http://petstore.swagger.wordnik.com/api", 
    "apis": 
    [ 
     { 
      "path":"/pet.{format}", 
      "description":"Operations about pets" 
     }, 
     { 
      "path":"/user.{format}", 
      "description":"Operations about user" 
     } 
    ] 
} 

但即使是原始文件上傳到我的Web服務器後,揚鞭UI告訴我:

Unable to fetch API Listing. Tried the following urls: 
http://www.myserver.org/resources.json 
http://www.myserver.org 
http://www.myserver.org/resources.json 
http://www.myserver.org/resources 

你能告訴是什麼原因導致揚鞭找不到我的json文件?

回答

4

我假設你要去www.myserver.org,它會引起swagger用戶界面?在Swagger UI中的「Explore」文本框中...確保輸入resources.json的位置。

我個人我昂首闊步API文檔建立這樣......

http://adamclerk.com/api   --Swagger UI 
http://adamclerk.com/api/doc  --returns json representing resources.js 
http://adamclerk.com/api/doc/donuts --returns json representing donut operations 

您可以檢出這裏更詳細的解釋 - Swagger With Static Documentation

如果您有任何問題隨時問。