This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3c08f0d9ab457bd29655f2cc01644b300b152767
Author: realistTheorist <realisttheor...@gmail.com>
AuthorDate: Sun Feb 11 12:35:22 2018 -0500

    CAMEL-12222: RestSwaggerServlet - added option to suppress 
"translateContextPath"
---
 .../camel/swagger/servlet/RestSwaggerServlet.java  | 26 ++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
 
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
index bc441a8..77ba9510 100644
--- 
a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
+++ 
b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/servlet/RestSwaggerServlet.java
@@ -34,6 +34,7 @@ import io.swagger.jaxrs.config.BeanConfig;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultClassResolver;
 import org.apache.camel.spi.ClassResolver;
+import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.swagger.RestApiResponseAdapter;
 import org.apache.camel.swagger.RestSwaggerSupport;
 import org.apache.camel.util.EndpointHelper;
@@ -58,6 +59,19 @@ public class RestSwaggerServlet extends HttpServlet {
 
     private String apiContextIdPattern;
     private boolean apiContextIdListing;
+    private boolean translateContextPath = true;
+
+
+    public boolean isTranslateContextPath() { return translateContextPath; }
+
+    /**
+     * Sets whether the context path of the request should be translated 
(true) or used as-is (false)
+     * Optional, Defaults to true
+     * @param translateContextPath
+     */
+    public void setTranslateContextPath(boolean translateContextPath) { 
this.translateContextPath = translateContextPath; }
+
+
 
     public String getApiContextIdPattern() {
         return apiContextIdPattern;
@@ -112,6 +126,11 @@ public class RestSwaggerServlet extends HttpServlet {
         if (listing != null) {
             apiContextIdListing = Boolean.valueOf(listing.toString());
         }
+        Object translate = parameters.remove("translateContextPath");
+        if (translate != null) {
+            translateContextPath = Boolean.valueOf(translate.toString());
+        }
+
     }
 
     @Override
@@ -189,7 +208,7 @@ public class RestSwaggerServlet extends HttpServlet {
                 if (!match) {
                     adapter.noContent();
                 } else {
-                    support.renderResourceListing(adapter, swaggerConfig, 
name, route, json, yaml, classResolver, null);
+                    support.renderResourceListing(adapter, swaggerConfig, 
name, route, json, yaml, classResolver, new RestConfiguration());
                 }
             }
         } catch (Exception e) {
@@ -226,6 +245,9 @@ public class RestSwaggerServlet extends HttpServlet {
      */
     private String translateContextPath(HttpServletRequest request) {
         String path = request.getContextPath();
+        if (!translateContextPath) {
+            return path;
+        }
         if (path.isEmpty() || path.equals("/")) {
             return "";
         } else {
@@ -237,4 +259,4 @@ public class RestSwaggerServlet extends HttpServlet {
         return path;
     }
 
-}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
davscl...@apache.org.

Reply via email to