swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Unable to Set up a swagger-ui for my already defined rest-apis

Open vijaya89 opened this issue 13 years ago • 2 comments

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?

vijaya89 avatar Jun 17 '13 07:06 vijaya89

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.

nizhu avatar Jun 17 '13 08:06 nizhu

This certainly looks like CORS. Please refer to the no-server sample as a reference.

fehguy avatar Jul 07 '13 08:07 fehguy