cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cxf git commit: CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Minor filter fixes.
Date Sun, 21 Dec 2014 15:35:32 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8fc7bfa3d -> 46ce1778d


CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Minor filter fixes.


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

Branch: refs/heads/master
Commit: 46ce1778d9a4d6a30e38b393a08dd4ecae2dbb09
Parents: 8fc7bfa
Author: reta <drreta@gmail.com>
Authored: Sun Dec 21 10:30:51 2014 -0500
Committer: reta <drreta@gmail.com>
Committed: Sun Dec 21 10:30:51 2014 -0500

----------------------------------------------------------------------
 .../java/demo/jaxrs/swagger/server/Server.java    |  3 ++-
 .../apache/cxf/jaxrs/swagger/SwaggerFeature.java  | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/46ce1778/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Server.java
b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Server.java
index 7d5fbb2..85d7eb9 100644
--- a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Server.java
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/java/demo/jaxrs/swagger/server/Server.java
@@ -45,7 +45,8 @@ public class Server {
         context.setResourceBase(
             getClass().getResource("/META-INF/resources/webjars/swagger-ui/2.0.24").toURI().toString());
         
-        servletHolder.setInitParameter("redirects-list", "/ /index.html /.*[.]js /css/.*
/images/.* lib/.*");
+        servletHolder.setInitParameter("redirects-list", 
+            "/ /index.html /.*[.]js /css/.* /images/.* lib/.* .*ico");
         servletHolder.setInitParameter("redirect-servlet-name", staticHolder.getName());
         servletHolder.setInitParameter("redirect-attributes", "javax.servlet.include.request_uri");
         servletHolder.setInitParameter("jaxrs.serviceClasses", Sample.class.getName());

http://git-wip-us.apache.org/repos/asf/cxf/blob/46ce1778/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