What I did was use Grizzly / Jersey to host swagger-ui , which is static content.
Here is the build.gradle part:
compile 'org.glassfish.jersey.core:jersey-server:2.22.1' compile 'org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.22.1' compile 'org.glassfish.jersey.containers:jersey-container-grizzly2-servlet:2.22.1'
Here's how to set up static content using Grizzly :
httpServer = GrizzlyWebContainerFactory.create(uri); httpServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("swagger-ui"), "/swagger");
swagger-ui is the folder in the root folder of the project.
Everything is fine when I access http://localhost/swagger/ , but when I try http://localhost/swagger it only gives a simple page without rendering, which seems to be missing all css / js files: 
I am wondering what is the best way to make a url without a trailing braid (/) the same as with a trailing slash.
Update: I raised a ticket for swagger-ui: https://github.com/swagger-api/swagger-ui/issues/1966 , but he said that this is a configuration problem with Grizzly , so another ticket for Grizzly : https : //java.net/jira/browse/GRIZZLY-1823
No solution found. I am thinking of using a different web server.
source share