Swagger UI not fetching resources (Uncaught SyntaxError: Unexpected token)

2,142 views
Skip to first unread message

Jorge Junior

unread,
Oct 16, 2013, 12:08:19 PM10/16/13
to swagger-sw...@googlegroups.com
Hi,

To initiate a project, I've downloaded the Swagger UI and created the following resource files:


localhost/docs/api/api-docs.json

{
    "apiVersion": "0.1",
    "swaggerVersion": "1.2",
    "basePath": "http://localhost/docs/api",
    "apis": [
        {
            "path": "/categories",
            "description": "Operations about categories"
        }
    ]
}

localhost/docs/api/categories.json

{
    "apiVersion": "0.1",
    "swaggerVersion": "1.2",
    "basePath": "http://localhost/docs/api",
    "resourcePath": "/categories",
    "apis": [
        {
            "path": "/categories",
            "description": "Operations about categories",
            "operations": [
                {
                    "method": "GET",
                    "nickname": "categoriesIndex",                    
                    "parameters": [],
                    "summary": "List all categories of store",
                    "notes": "All categories that you have added in administrative area will be displayed",
                    "responseMessages": [],
                }
            ]
        }
    ]

}

Apparently, my specs files are right. On Chrome, UI stops in "fetching resource list" message, and this error in developers console: "Uncaught SyntaxError: Unexpected token"



Network tab:


Am I missing something? What i'm doing wrong?



Jorge Junior

unread,
Oct 17, 2013, 6:50:55 PM10/17/13
to swagger-sw...@googlegroups.com
Just to check: the problem was:

1: an additional commas in categories.json files
2: wrong address provided in index.html (was pointing to the project root, instead of api specs json)

Answers provided in irc channel by @tony.
Reply all
Reply to author
Forward
0 new messages