Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger UI error: Unable to fetch API Listing

Tags:

swagger

I'm documenting a REST web API with Swagger. I've downloaded the petstore example. It consists of the resources.json which references pet.json and 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"
        }
    ]
}

But even after uploading the original files to my web server, Swagger UI tells me:

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

Can you tell what causes Swagger not find my json file?

like image 929
Norbert Avatar asked Jul 11 '12 18:07

Norbert


1 Answers

I'm assuming you're going to www.myserver.org and it brings up the swagger ui? In the "Explore" textbox in the Swagger UI... be sure to type in the location of your resources.json.

I personally have my swagger api documentation set up this way...

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

you can checkout a more detailed explaination here - Swagger With Static Documentation

If you have any more questions feel free to ask.

like image 122
adamclerk Avatar answered Oct 02 '22 03:10

adamclerk