Vision Statement

Provide a library that can serve swagger UI in Jersey application. Inspiration for this library was the SpringFox Swagger UI project that works with spring boot application.

Use Case

Suppose you have a runnable Jar Jersey REST API application with Open API annotations and would like to provide a swagger UI for API consumers to learn and play with your APIs. Swagger UI comes as a set of static Javascript files that need to be included in your application. In addition, you need to configure a web context that will serve swagger UI pages. By including itzap-jerseyswagger.jar in your project you will get an endpoint that will load functional Swagger UI with your API definitions.

Implementation Details

Here is the code that starts embedded Tomcat in the project that I described in my previous post itzap-message. I modified it to use Open API annotations and include swagger UI.

private static void start() throws Exception {

        String contextPath = "";
        String appBase = ".";
        String port = System.getenv("PORT");
        if (port == null || port.isEmpty()) {
            port = "8025";

        Tomcat tomcat = new Tomcat();

        Context context = tomcat.addWebapp(contextPath, appBase);

        Tomcat.addServlet(context, "jersey-container-servlet",
                new ServletContainer(resourceConfig()));
        context.addServletMappingDecoded(UDecoder.URLDecode("/v1/itzap/message/*", Charset.defaultCharset()),

        SwaggerContext.addSwaggerServlet(tomcat, context,


The code to notice here is:

SwaggerContext.addSwaggerServlet(tomcat, context,

That all you need to do to add swagger UI to the REST API application.

There are a few properties that need to be added to the project configuration.


Now you can start the project java -jar message-impl/target/message-impl-0.0.1-SNAPSHOT.jar and navigate your browser to




itzap-jerseyswagger library is designed to provide swagger UI endpoint to the Jersey REST API application.


Include itzap-jerseyswagger dependency to your project.


add the following properties to the application config file


The following code will add swaggerUI artifacts and context

SwaggerContext.addSwaggerServlet(tomcat, context,

How To Build

  • Clone the following projects:
    • git clone
    • git clone
  • Build all projects
    • cd itzap-parent && mvn clean install
    • cd ../itzap-common && mvn clean install

Visit my ITZap blog to read more about this project.


Complete implementation can be found here:

Leave a Reply

Your email address will not be published. Required fields are marked *

2 replies
  • golden goose says:

    I want to show appreciation to you for rescuing me from this particular setting. Because of looking through the online world and coming across solutions which were not pleasant, I assumed my life was done. Being alive minus the approaches to the issues you’ve fixed by means of your guide is a critical case, as well as ones which might have adversely damaged my entire career if I had not noticed the blog. Your own knowledge and kindness in taking care of every aspect was very useful. I am not sure what I would have done if I had not encountered such a step like this. I can also at this moment look ahead to my future. Thanks a lot so much for your skilled and results-oriented help. I will not think twice to endorse your web blog to anyone who needs assistance about this matter.

  • I just wanted to jot down a small comment in order to express gratitude to you for all the marvelous tips and hints you are writing on this website. My prolonged internet search has now been compensated with sensible points to go over with my family. I ‘d state that that we visitors actually are quite blessed to live in a notable community with so many awesome individuals with helpful advice. I feel somewhat happy to have used the site and look forward to so many more fabulous times reading here. Thanks once again for all the details.