Swagger UI and no response problem

4,649 views
Skip to first unread message

Jack

unread,
Feb 8, 2016, 3:32:52 PM2/8/16
to Swagger
Hi,

Thanks to previous help, mostly from Ron. I got my json and yaml file.

I followed this http://swagger.io/swagger-ui/ to set up my swagger UI. But now, I still got nothing from http://localhost:8080/

My own server is surely started. I do not know how I incorporate this swagger UI into my application server. Can anyone please help me ?


And 


into the blank at  http://petstore.swagger.io 

I can see my API docs, any one with @API annotations. But I can not get a valid response.  My server certainly works since I got valid response from Advanced Rest Client Plugin in Chrome browser. 

All I got is 

{

  "error": "no response from server"

}


Is that a CORS problem ? And if I can have my own swagger UI, so I do not have to deal with it, since it is not cross domain anymore. 


Thanks,

Jack

Jack

unread,
Feb 8, 2016, 4:50:34 PM2/8/16
to Swagger
Now I got localhost:8080/ UI part showed up.

But I still can not get valid response. 

Any help is hight appreciated. 

Ron Ratovsky

unread,
Feb 8, 2016, 6:35:38 PM2/8/16
to swagger-sw...@googlegroups.com
Yeah, that would be a CORS issue. It’s not enough to have them hosted on the same machine, they need to be hosted on the same application server (that is, the same port as well) in order to avoid it.
Of course, in most cases enabling CORS should be easy.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jack

unread,
Feb 9, 2016, 1:35:32 PM2/9/16
to Swagger
I do a curl test . I got this 

$curl -I "http://localhost/api/1.0/swagger.json"

HTTP/1.1 200 OK

Date: Tue, 09 Feb 2016 18:33:00 GMT

Server: Jetty(7.4.5.v20110725)

Pragma: no-cache

Cache-Control: no-cache

Expires: 0

Content-Type: application/json

Access-Control-Allow-Origin: *   //-----> does it mean the server supports cross domain api call already ?

Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE

Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control




Access-Control-Allow-Origin: *   //-----> does it mean the server supports cross domain api call already ? I do not know how to enable CORS.Putting sth in the header of request?



Thanks,
Jack
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Feb 9, 2016, 1:42:58 PM2/9/16
to swagger-sw...@googlegroups.com
Can you run the same curl (-I) on one of your API calls?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 9, 2016, 2:09:27 PM2/9/16
to Swagger

$ curl -I "http://localhost/api/1.0/notice"

HTTP/1.1 401 Unauthorized

Date: Tue, 09 Feb 2016 19:08:15 GMT

Server: Jetty(7.4.5.v20110725)

Pragma: no-cache

Cache-Control: must-revalidate,no-cache,no-store

Content-Length: 1385

Content-Type: text/html;charset=ISO-8859-1

Set-Cookie: crowd.token_key=null;Version=1;Comment=;Path=/;Max-Age=0

Access-Control-Allow-Origin: *

Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE

Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control


$ curl -I "http://localhost/api/1.0/logs"

HTTP/1.1 405 Method Not Allowed

Date: Tue, 09 Feb 2016 19:08:19 GMT

Server: Jetty(7.4.5.v20110725)

Pragma: no-cache

Cache-Control: must-revalidate,no-cache,no-store

Allow: OPTIONS

Content-Type: text/html;charset=ISO-8859-1

Content-Length: 1395

Access-Control-Allow-Origin: *

Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE

Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control



Ron Ratovsky

unread,
Feb 9, 2016, 2:22:19 PM2/9/16
to swagger-sw...@googlegroups.com
Not sure if the 401/405 may be causing the issue, but we can investigate further.
Can you check the calls in the network tab of your browser’s developer tools?
When clicking the try it out button you should see two calls, one with OPTIONS and after that the actual call.
If you see the second call, check that you’re getting the result that you expect to get.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 9, 2016, 2:34:16 PM2/9/16
to Swagger
Hi,


using Chrome browser and in the network tab in developer tool, I just see one call. There is no OPTIONS.

Thank youm
Jack

Ron Ratovsky

unread,
Feb 9, 2016, 2:35:15 PM2/9/16
to swagger-sw...@googlegroups.com
I was talking about running the call via’s swagger-ui’s try it now button.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 9, 2016, 2:36:17 PM2/9/16
to Swagger
And yes, both are just one api call without OPTIONS call first.

I got 200 status. And response successfully back

Ron Ratovsky

unread,
Feb 9, 2016, 2:38:02 PM2/9/16
to swagger-sw...@googlegroups.com
What is the content type of the request/response? What is the actual content of the response you’re getting?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 9, 2016, 2:52:46 PM2/9/16
to Swagger
Oh.

In the UI, the type is always application/json.

Still, I see one call without OPTIONS. And all in red, 401 status back. 



Curl

curl -X GET --header 'Accept: application/json' 'http://companydomain-route to localhost/api/1.0/logs/:idididididididid?startDate=2015-10-01&endDate=2015-12-01'

Request URL

http://company.domain route to localhost/api/1.0/logs/:idididididididid?startDate=2015-10-01&endDate=2015-12-01

Response Body

no content

Response Code

0

Response Headers

Ron Ratovsky

unread,
Feb 9, 2016, 2:54:40 PM2/9/16
to swagger-sw...@googlegroups.com
Then you probably need to disable authentication for OPTIONS calls on your server.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Message has been deleted

Jack

unread,
Feb 9, 2016, 7:19:20 PM2/9/16
to Swagger
Is enabling CORS still an option?

And is there any side effect for disabling auth for OPTIONS calls?

Ron Ratovsky

unread,
Feb 10, 2016, 3:27:38 PM2/10/16
to swagger-sw...@googlegroups.com
Not an expert on that, so can’t say if there are side effects. As a first step, I’d at least try to disable auth and see if that resolves the issue.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 10, 2016, 3:34:16 PM2/10/16
to Swagger
I see. I am now running swagger UI on another server. 

So if I put swagger ui with my application server, ( add Swagger UI in pom.xml, then can pull ui directly from Git hub ) the same port, does it solve the problem automatically ? 

As you said " they need to be hosted on the same application server (that is, the same port as well) in order to avoid it."

Ron Ratovsky

unread,
Feb 10, 2016, 3:35:26 PM2/10/16
to swagger-sw...@googlegroups.com
It should solve the issue, yes.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Jack

unread,
Feb 17, 2016, 7:40:38 PM2/17/16
to Swagger
Hi,   I have swagger ui plugin ready now and I can access at localhost/swagger/index.html

But when I put in http://localhost/api/1.0/swagger.json  which I should get  a colorful page, I still got nothing. It says "fetching resource list: http://localhost/api/1.0/swagger.json"

or "Can't read from server. It may not have the appropriate access-control-origin settings." if I put http://localhost:8080/api/1.0/swagger.json

Any idea?

Thanks,
Jack

Ron Ratovsky

unread,
Feb 18, 2016, 7:00:56 PM2/18/16
to swagger-sw...@googlegroups.com
Can you open any of those URLs directly in your browser?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages