7

我正在使用Swagger记录 REST Web API 。我已经下载了 petstore 示例。它由resources.jsonwhich 引用pet.json和组成user.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"
        }
    ]
}

但即使在将原始文件上传到我的网络服务器之后,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 文件吗?

4

1 回答 1

4

我假设你要去 www.myserver.org 并且它带来了招摇的用户界面?在 Swagger UI 的“探索”文本框中...确保输入 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 With Static Documentation

如果您还有其他问题,请随时提出。

于 2012-07-22T03:15:34.300 回答