2012-07-11 31 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

如果您有任何问题随时问。