cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Merging to 3.0.x a fix to to do with SwaggerFeature running as a filter done by Andriy Redko
Date Mon, 22 Dec 2014 11:04:59 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes cdb816233 -> 74860c548


Merging to 3.0.x a fix to to do with SwaggerFeature running as a filter done by Andriy Redko


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/74860c54
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/74860c54
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/74860c54

Branch: refs/heads/3.0.x-fixes
Commit: 74860c548fb6687ddc5fe0b869dbb1d10e963efa
Parents: cdb8162
Author: reta <drreta@gmail.com>
Authored: Sun Dec 21 10:30:51 2014 -0500
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Dec 22 11:04:19 2014 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/swagger/SwaggerFeature.java  | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/74860c54/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
index 383211c..8900ba1 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
@@ -21,6 +21,8 @@ package org.apache.cxf.jaxrs.swagger;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
@@ -168,6 +170,9 @@ public class SwaggerFeature extends AbstractFeature {
 
     @PreMatching
     private static class SwaggerContainerRequestFilter implements ContainerRequestFilter
{
+        private static final String APIDOCS_LISTING_PATH = "api-docs";
+        private static final Pattern APIDOCS_RESOURCE_PATH = Pattern.compile(APIDOCS_LISTING_PATH
+ "(/.+)");
+        
         private ApiListingResourceJSON apiListingResource;
         @Context
         private MessageContext mc;
@@ -178,10 +183,19 @@ public class SwaggerFeature extends AbstractFeature {
         @Override
         public void filter(ContainerRequestContext requestContext) throws IOException {
             UriInfo ui = mc.getUriInfo();
-            if (ui.getPath().endsWith("api-docs")) {
+            if (ui.getPath().endsWith(APIDOCS_LISTING_PATH)) {
                 Response r = 
-                    apiListingResource.apiDeclaration("", null, mc.getServletConfig(), mc.getHttpHeaders(),
ui);
+                    apiListingResource.resourceListing(null, mc.getServletConfig(), mc.getHttpHeaders(),
ui);
                 requestContext.abortWith(r);
+            } else {
+                final Matcher matcher = APIDOCS_RESOURCE_PATH.matcher(ui.getPath());
+                
+                if (matcher.find()) {
+                    Response r = 
+                        apiListingResource.apiDeclaration(matcher.group(1), 
+                            null, mc.getServletConfig(), mc.getHttpHeaders(), ui);
+                    requestContext.abortWith(r);                
+                }
             }
         }
         


Mime
View raw message