title: Swagger UI with Apache Camel 3 (servlet) + SpringBoot 2
body: <p>New to Camel + SpringBoot + Swagger.
  Created some REST APIs using Camel 3.8.0 and SpringBoot 2.4.2 (using Camel's Servlet on Default TomCat of SpringBoot).</p>
  <p>Here is pom.xml</p>
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.4.2&lt;/version&gt;
      &lt;relativePath/&gt;
  &lt;/parent&gt;
  
  &lt;groupId&gt;com.crsardar.java.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;hands-on-camel-springboot&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;properties&gt;
      &lt;maven.compiler.source&gt;8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;8&lt;/maven.compiler.target&gt;
  
      &lt;camelVersion&gt;3.8.0&lt;/camelVersion&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;!-- SpringBoot --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Camel --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
          &lt;artifactId&gt;camel-spring-boot-bom&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
          &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-jackson&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-servlet-starter&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
          &lt;artifactId&gt;camel-spring-boot-starter&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
          &lt;artifactId&gt;camel-rest-swagger-starter&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-swagger-java&lt;/artifactId&gt;
          &lt;version&gt;${camelVersion}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
                  &lt;artifactId&gt;*&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.webjars&lt;/groupId&gt;
          &lt;artifactId&gt;swagger-ui&lt;/artifactId&gt;
          &lt;version&gt;2.2.10&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.webjars&lt;/groupId&gt;
          &lt;artifactId&gt;webjars-locator&lt;/artifactId&gt;
          &lt;version&gt;0.40&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;!-- Others --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
          &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;version&gt;1.18.18&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  <p>Configuration and REST end points -</p>
  <pre><code>package com.crsardar.java.apache.camel;
  
  import com.crsardar.java.dao.Order;
  import org.apache.camel.builder.RouteBuilder;
  import org.apache.camel.model.rest.RestBindingMode;
  import org.springframework.http.MediaType;
  import org.springframework.stereotype.Component;
  
  @Component
  public class CamelController extends RouteBuilder {
  
      @Override
      public void configure() throws Exception {
  
          restConfiguration()
                  .component(&quot;servlet&quot;)
                  .port(8080)
                  .host(&quot;127.0.0.1&quot;)
                  .apiContextPath(&quot;api-docs&quot;)
                  .apiContextIdPattern(&quot;#name#&quot;)
                  .apiProperty(&quot;api.title&quot;, &quot;Test REST API&quot;)
                  .apiProperty(&quot;api.version&quot;, &quot;v1&quot;)
                  .apiProperty(&quot;cors&quot;, &quot;true&quot;)
                  .bindingMode(RestBindingMode.json);
  
          rest().post(&quot;/order&quot;)
                  .produces(MediaType.APPLICATION_JSON_VALUE)
                  .type(Order.class)
                  .outType(Order.class)
                  .to(&quot;bean:orderService?method=addOrder(${body})&quot;);
  
          rest().get(&quot;/order&quot;)
                  .produces(MediaType.APPLICATION_JSON_VALUE)
                  .to(&quot;bean:orderService?method=getOrders()&quot;);
  
      }
  }
  </code></pre>
  <p>I am trying to document it and give an option to test it using Swagger UI.</p>
  <p>If I run the application and hit <code>http://127.0.0.1:8080/api-docs</code> I am getting Swagger's API documentation.</p>
  <p><strong>But, I can not try it using Swagger UI, How can I make Swagger UI working on it?</strong></p>
  <p>I do not know - Whether Swagger-UI is working on this app or not? If working, what will be the URL for Swagger-UI?</p>
  <p>Complete code is here <a href="https://github.com/crsardar/hands-on-java/tree/master/hands-on-camel-springboot" rel="nofollow noreferrer">https://github.com/crsardar/hands-on-java/tree/master/hands-on-camel-springboot</a></p>