Can I use localhost as host in swaggerhub?
Hi there - I'm new to swaggerhub so noob question alert!
Can I use swaggerhub (app.swaggerhub.com) to test out apis hosted on my localhost? The CURL being generated by swaggerhub is perfect and works if I run it from git bash (I'm on windows). curl -X GET "http://localhost:57280/api/open" -H "accept: application/json".
However, when I click execute on swaggerhub it gives this error:
content-length: 0 date: Sun, 11 Mar 2018 18:24:25 GMT server: nginx/1.8.0 + Phusion Passenger 5.0.22 status: 403, 403 Forbidden x-powered-by: Express, Phusion Passenger 5.0.22
This leads me to believe that the URL is getting sent to swaggerhub's servers for resolution, and thus clearly localhost won't mean the same thing "over there". Or is swaggerhub editor/UI an SPA which emits the URL locally to my browser such that it _could_ resolve properly, but I'm just doing something wrong?
Full swagger ..
title: 'Basic features of azure b2c'
description: 'Basic features of azure b2c'
host : 'localhost:57280'
basePath : '/api'
# In this operation we do not apply the security, because it was applied globally above.
# The security will be applied to this operation for that reason.
summary: Server example operation
description: This is an example operation to show how security is applied to the call.
Re: Can I use localhost as host in swaggerhub?
"Try it out" requests are proxied through SwaggerHub servers in order to bypass CORS restrictions in browsers. So, SwaggerHub needs the API server to be reachable over the public Internet. Localhost and local IPs are not supported as target servers.
To test against localhost, you can load your API definition into standalone Swagger UI, e.g.:
and test the requests from there.
Make sure to replace app.swaggerhub.com with api.swaggerhub.com in your API definition address in the link above.
You may also need to enable CORS on your localhost in order for "try it out" to work.
Also feel free to submit an enhancement request for SwaggerHub:
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️