I'm just beginning to use Swagger, and I'm trying to create my own resource definition and API declaration. They're not working, and I need some help figuring out why.
When I load Swagger it displays the message "200 : OK
http://localhost/swagger-ui/dist?api_key=special-key." In other words, "I found the resource definition at
http://localhost/swagger-ui/dist, and everything is OK." But everything is not OK; the resource definition refers to an API declaration, and Swagger doesn't display it. Nor does it tell me why not.
I've found that I can make any sort of change to the resource definition, even introducing JSON syntax errors, without affecting Swagger's response. I can even rename the file to something other than api-docs.json so that Swagger can't find it. The only way I can to make Swagger say something other than a "OK" is to enter a URL in the Swagger heading that refers to a non-existent file or directory. Then I get a message that says "Can't read Swagger JSON from..." (But if the URL refers to a directory that exists but doesn't contain an api-docs.json file, I get "OK.")
Here's what my resource file looks like. (I've changed some of the values to conceal possibly confidential information.) It's in the document space's /swagger-ui/dist directory. An API declaration file named xyz.json is in the same directory.
{
apiVersion: "0.1",
swaggerVersion: "1.1",
basePath: "localhost/swagger-ui/dist",
apis: [
{
path: "/xyz.{format}",
description: "Prototype xyz API"
}
]
}
That's the problem.
The metaproblem is that I don't see any way to diagnose the problem, short of "debugging" the JavaScript code. My customary approach to this type of problem is to start with the distributed example, which presumably works, and look for a significant difference in my own non-functioning case. If I can't find one, my fallback strategy is to transform the distributed example into what need a little at a time. If it breaks at some point, I have a good idea where the problem is; if it doesn't, I've completed my task even if I haven't figured out what originally made my code fail to work.
But here there
is no distributed example; the example is on the Wordnix server where I can't examine it directly.