I'm trying to hook in swagger-ui into a java dynamic web project. Currently, the rest api works and I am able to hit the following url and see the json: http://localhost:8080/test/swagger.json
My project uses Java, Swagger, Wildfly, and RestEasy.
public class SwaggerServlet extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setHost("localhost:8080");
beanConfig.setBasePath("/test");
beanConfig.setResourcePackage("com.test.rest");
beanConfig.setScan(true);
}
}
Following the tutorial found at this link: http://kjkrol.blogspot.ca/2015/01/how-to-integrate-swagger-ui-with-java.html to hook up swagger ui doesn't seem to work for me. I downloaded swagger-ui repo from github. I created a swagger folder in the following location:
my-project/src/main/webapp/swagger
In the swagger folder, copied the dist folder from the swagger-ui project. I also edited the URL as the tutorial suggests:
// Build a system
const ui = SwaggerUIBundle({
url: "test/api-docs",
dom_id: '#swagger-ui',
I ended up following an example found at this link: https://github.com/K0NRAD/swagger-wildfly-resteasy
It works! I noticed that the documentation takes a slightly different approach that for some reason wasn't working for me...
Thanks everyone!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.