I would like to use swagger on Weblogic but I do not know how to bootstrap it via Java.
There is no Spring dependency in the project, no web.xml. It is a simple JAX-RS project.
A request to http://localhost:7001/..../swagger.json produces the proper content but I need to connfigure Swagger's base package and other staff.
I have tried to use the following solution but it does not work: public class SwaggerJaxrsConfig extends HttpServlet {
public class SwaggerConfig extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
System.out.println("hello!!!!!!!!!!!!!!!!!!!!!!");
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setBasePath("http://localhost:7001/.../resources/swagger.json");
beanConfig.setResourcePackage("a.b.c");
beanConfig.setScan(true);
}
}
Any idea how to bootstrap Swagger?
Finnaly I have figure the solution out:
The following code works fine on Weblogic 12.2.1:
package com.xxx.yyy.rest.swagger;
import io.swagger.jaxrs.config.DefaultJaxrsConfig;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
@WebServlet(
name = "SwaggerBootstrapServlet",
urlPatterns = { "/SwaggerBootstrapServlet" },
loadOnStartup = 1,
initParams = {
@WebInitParam(name = "swagger.api.basepath", value = "http://...:7001/.../resources"),
@WebInitParam(name = "api.version", value = "1.0"),
@WebInitParam(name = "swagger.api.title", value = "... REST API"),
@WebInitParam(name = "swagger.pretty.print", value = "true")
}
)
public class SwaggerBootstrapServlet extends DefaultJaxrsConfig {
}