Unable to Set up a swagger-ui for my already defined rest-apis
I downloaded the swagger-ui code from https://github.com/wordnik/swagger-ui/tree/master/dist , and running the UI from http://localhost:8090.
I have My application and its api's in http://localhost:8080 which are written in java(not jersey).
My user.json file is in http://localhost:8090/docs/api-docs/user.json, but I am referring the api in localhost:8080
My user.json file is as below
{ "apiVersion":"0.2", "swaggerVersion":"1.1", "basePath":"http://localhost:8080/dma/api/auto", "resourcePath":"/workflow", "apis":[ { "path":"/workflow", "description":"Operations about user", "operations":[ { "httpMethod":"GET", "summary":"Logs user into the system", "responseClass":"string", "nickname":"loginUser", "consumes": ["application/xml"], "produces": ["application/xml"], "parameters":[ { "name":"workflow", "description":"workflow name", "paramType":"query", "required":true, "allowMultiple":false, "dataType":"string" }
],
"errorResponses":[
{
"code":400,
"reason":"Invalid username and password combination"
}
]
}
]
}
]
when I try to run swagger-ui, Therequest url l is constructed good
But I am getting 0 in response code and no value in response body. Can body help me whether I can have swgger-ui in one server and apis in another server?
You can, but your API server will need to add some headers to support Cross Site Resource Sharing. Refer to https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS and https://groups.google.com/forum/?fromgroups#!topic/swagger-swaggersocket/9mSNi1fqKVU.
This certainly looks like CORS. Please refer to the no-server sample as a reference.