Swagger UI错误:无法获取API列表

7

我正在使用 Swagger 记录 REST Web API。我已经下载了 petstore 的示例。它包含了 resources.json,其中引用了 pet.jsonuser.json

{
    "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服务器上,Swagger 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

您能告诉我Swagger找不到我的JSON文件的原因吗?

1个回答

4

我假设你正在访问www.myserver.org并打开了Swagger UI?在Swagger UI的“Explore”文本框中,请确保输入您的resources.json文件的位置。

就我个人而言,我的Swagger 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与静态文档 如果您有任何其他问题,请随时提出。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接