FIrstly, Swagger Basepath that you have in the web.xml is used by the swagger UI when you use 'try it out' feature of UI. i.e say if you have a GET request for "User" api than, when you 'try it out', swagger ui would first the following url "localhost:8080/<proje-path>/rest/user". So you base path should reflect it.
Now to get you swagger.json you need to access the "localhost:8080/<project-path>/rest/swagger.json" not api-docs, even the url in the index.html should reflect the same uri. On Monday, July 25, 2016 at 12:51:09 AM UTC-7, Vishal Thakur wrote: > > Hi > > Could you resolve this issue. I am also facing same issue. > > > On Tuesday, March 29, 2016 at 1:33:36 AM UTC+5:30, baskar ia wrote: >> >> Hi I'm new to Swagger. I need some help to setting it up. >> >> I have implemented Swagger version v2.1.4 in my JAX-RS 1.5. I'm getting >> "Can't >> read swagger JSON from http://localhost:". >> >> *my ivy :* <dependency org="io.swagger" name="swagger-jersey-jaxrs" >> rev="1.5.4"/> >> >> *In web-inf/app folder* i have copied the swagger UI dist folder and >> placed the files >> >> *my web.xml* >> >> <servlet> >> <servlet-name>jersey</servlet-name> >> >> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> >> <init-param> >> >> <param-name>com.sun.jersey.config.property.packages</param-name> >> <param-value> >> io.swagger.jaxrs.json, >> io.swagger.jaxrs.listing, >> {My web service class path} >> </param-value> >> </init-param> >> </servlet> >> >> <servlet-mapping> >> <servlet-name>jersey</servlet-name> >> <url-pattern>/rest/*</url-pattern> >> </servlet-mapping> >> >> <servlet> >> <servlet-name>Jersey2Config</servlet-name> >> >> <servlet-class>io.swagger.jaxrs.config.DefaultJaxrsConfig</servlet-class> >> <init-param> >> <param-name>api.version</param-name> >> <param-value>1.0.0</param-value> >> </init-param> >> <init-param> >> <param-name>swagger.api.basepath</param-name> >> <param-value>http://localhost:<Port>/<project >> path>/rest/api-docs</param-value> >> </init-param> >> <load-on-startup>2</load-on-startup> >> </servlet> >> >> *service Class :* >> >> @Api(value = "/CreateServices") - in class level >> >> @ApiOperation(value = "Create Customer", notes = "Create Customer.") - >> method level >> >> *In index.html* >> >> I didn't changed anything other than the url path: >> >> >> *url = "http://localhost <http://localhost>:<port>/<server >> path>/rest/api-docs/"* >> But i'm getting the below error when i try to hit the url : >> >> I'm getting "Can't read swagger JSON from http://localhost:". >> >> -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
