api - why I am getting http 404 after heating http://localhost:3636/RestSwagger/rest/swagger.json -
hi while trying acess swagger.json rest api http://localhost:3636/restswagger/rest/swagger.json why getting http 404 response. below providing whole code please follow pom.xml ---------- <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-server</artifactid> <version>1.8</version> </dependency> <dependency> <groupid>io.swagger</groupid> <artifactid>swagger-jaxrs</artifactid> <version>1.5.8</version> </dependency> web.xml --------- <servlet> <servlet-name>jersey-serlvet</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>com.rest.swagger</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jersey-serlvet</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <servlet> <servlet-name>swaggerbootstrap</servlet-name> <servlet-class>com.rest.swagger.swaggerapplication</servlet-class> <load-on-startup>2</load-on-startup> </servlet> rest application ------------------- package com.rest.swagger; import io.swagger.annotations.api; import io.swagger.annotations.apioperation; import io.swagger.annotations.apiparam; import io.swagger.annotations.apiresponse; import io.swagger.annotations.apiresponses; import javax.ws.rs.formparam; import javax.ws.rs.post; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.core.response; @path("/customers") @api(value = "/customers", description = "manage customer") public class restserviceformparam { @post @path("/addcustomer") @produces("text/html") @apioperation(value = "get customer details form page", response = restserviceformparam.class, responsecontainer = "list") @apiresponses({ @apiresponse(code = 200, message = "customer details message name , country") }) public response getresultbypassingvalue( @apiparam(value = "page fetch name , country", required = true) @formparam("namekey") string name, @formparam("countrykey") string country) { string output = "<font face='verdana' size='2'>" + "web service has added customer information name - <u>" + name + "</u>, country - <u>" + country + "</u></font>"; return response.status(200).entity(output).build(); } } swagger servlet application --------------------------------
package com.rest.swagger;
import io.swagger.jaxrs.config.beanconfig;
import javax.servlet.servletconfig;
- list item
import javax.servlet.servletexception; import javax.servlet.http.httpservlet;
public class swaggerapplication extends httpservlet {
private static final long serialversionuid = -6039834823506457822l; @override public void init(servletconfig config) throws servletexception { super.init(config); beanconfig beanconfig = new beanconfig(); final string contextpath = config.getservletcontext().getcontextpath(); final stringbuilder sbbasepath = new stringbuilder(); sbbasepath.append(contextpath); sbbasepath.append("/rest"); beanconfig.setbasepath(sbbasepath.tostring()); // api info beanconfig.setversion("0.1"); beanconfig.settitle("my swagger app"); beanconfig.setresourcepackage("com.rest.swagger"); beanconfig.setscan(true); }
}
Comments
Post a Comment