Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 871df8c66 -> bdc67fbc2


[CXF-6836] More SwaggerUtils work


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

Branch: refs/heads/3.1.x-fixes
Commit: bdc67fbc286a3c8c84e3d4b044801ae6366e005d
Parents: 871df8c
Author: Sergey Beryozkin <sberyoz...@gmail.com>
Authored: Thu Dec 1 13:56:14 2016 +0000
Committer: Sergey Beryozkin <sberyoz...@gmail.com>
Committed: Thu Dec 1 13:58:20 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/model/UserApplication.java |   9 ++
 .../apache/cxf/jaxrs/swagger/SwaggerUtils.java  | 135 +++++++------------
 .../cxf/jaxrs/swagger/SwaggerUtilsTest.java     |  67 ++++-----
 .../src/test/resources/swagger12.json           |  27 ----
 .../src/test/resources/swagger20.json           |  90 +++++++------
 .../AbstractSwagger2ServiceDescriptionTest.java |  16 ++-
 .../jaxrs/description/group1/BookStore.java     |   5 +-
 .../systest/jaxrs/description/swagger2-json.txt |   1 -
 .../jaxrs/description/swagger2-noano-json.txt   |   1 -
 9 files changed, 153 insertions(+), 198 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserApplication.java
----------------------------------------------------------------------
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserApplication.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserApplication.java
index 404416d..eec7e83 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserApplication.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserApplication.java
@@ -25,6 +25,7 @@ import java.util.Map;
 public class UserApplication {
 
     private String name;
+    private String basePath;
     private List<UserResource> resources; 
     
     public UserApplication() {
@@ -62,4 +63,12 @@ public class UserApplication {
         }
         return map;
     }
+
+    public String getBasePath() {
+        return basePath;
+    }
+
+    public void setBasePath(String basePath) {
+        this.basePath = basePath;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
----------------------------------------------------------------------
diff --git 
a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
 
b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
index c0d7c6b..477fc59 100644
--- 
a/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
+++ 
b/rt/rs/description-swagger/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
@@ -20,22 +20,26 @@ package org.apache.cxf.jaxrs.swagger;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
 import org.apache.cxf.jaxrs.model.Parameter;
 import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserApplication;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -61,66 +65,64 @@ public final class SwaggerUtils {
     private SwaggerUtils() {
         
     }
-    public static UserResource getUserResource(String loc) {
-        return getUserResource(loc, BusFactory.getThreadDefaultBus());
+    public static UserApplication getUserApplication(String loc) {
+        return getUserApplication(loc, BusFactory.getThreadDefaultBus());
     }
-    public static UserResource getUserResource(String loc, Bus bus) {
+    public static UserApplication getUserApplication(String loc, Bus bus) {
         try {
             InputStream is = ResourceUtils.getResourceStream(loc, bus);
             if (is == null) {
                 return null;
             }
-            return getUserResourceFromStream(is);
+            return getUserApplicationFromStream(is);
         } catch (Exception ex) {
             LOG.warning("Problem with processing a user model at " + loc);
         }
         return null;
     }
-    public static UserResource getUserResourceFromStream(InputStream is) 
throws IOException {
-        return getUserResourceFromJson(IOUtils.readStringFromStream(is));
+    public static UserApplication getUserApplicationFromStream(InputStream is) 
throws IOException {
+        return getUserApplicationFromJson(IOUtils.readStringFromStream(is));
     }
-    public static List<UserResource> 
getUserResourcesFromResourceObjects(List<String> jsonObjects) {
-        List<UserResource> resources = new ArrayList<UserResource>();
-        for (String json : jsonObjects) {
-            resources.add(getUserResourceFromJson(json));
-        }
-        return resources;
-    }
-    public static UserResource getUserResourceFromJson(String json) {
+    public static UserApplication getUserApplicationFromJson(String json) {
         JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
         Map<String, Object> map = reader.fromJson(json);
+    
+        UserApplication app = new UserApplication();
+        String relativePath = (String)map.get("basePath");
+        app.setBasePath(StringUtils.isEmpty(relativePath) ? "/" : 
relativePath);
         
-        if (map.containsKey("swaggerVersion")) {
-            return getUserResourceFromSwagger12(map);
+        
+        Map<String, List<UserOperation>> userOpsMap = new 
LinkedHashMap<String, List<UserOperation>>();
+        Set<String> tags = new HashSet<String>();
+        List<Map<String, Object>> tagsProp = 
CastUtils.cast((List<?>)map.get("tags"));
+        if (tagsProp != null) {
+            for (Map<String, Object> tagProp : tagsProp) {
+                tags.add((String)tagProp.get("name"));
+            }
         } else {
-            return getUserResourceFromSwagger20(map);
+            tags.add("");
+        }
+        for (String tag : tags) {
+            userOpsMap.put(tag, new LinkedList<UserOperation>());
         }
         
-    }
-    private static UserResource getUserResourceFromSwagger20(Map<String, 
Object> map) {
-        UserResource ur = new UserResource();
-        String relativePath = (String)map.get("basePath");
-        ur.setPath(relativePath == null ? "/" : relativePath);
-        
-        List<String> resourceProduces = 
CastUtils.cast((List<?>)map.get("produces"));
-        ur.setProduces(listToString(resourceProduces));
-        
-        List<String> resourceConsumes = 
CastUtils.cast((List<?>)map.get("consumes"));
-        ur.setConsumes(listToString(resourceConsumes));
         
-        List<UserOperation> userOps = new LinkedList<UserOperation>();
         Map<String, Map<String, Object>> paths = CastUtils.cast((Map<?, 
?>)map.get("paths"));
         for (Map.Entry<String, Map<String, Object>> pathEntry : 
paths.entrySet()) {
-            
             String operPath = pathEntry.getKey();
             
             Map<String, Object> operations = pathEntry.getValue();
             for (Map.Entry<String, Object> operEntry : operations.entrySet()) {
+                
                 UserOperation userOp = new UserOperation();
                 userOp.setVerb(operEntry.getKey().toUpperCase());
-                userOp.setPath(operPath);
                 
                 Map<String, Object> oper = CastUtils.cast((Map<?, 
?>)operEntry.getValue());
+                List<String> opTags = 
CastUtils.cast((List<?>)oper.get("tags"));
+                String opTag = opTags == null ? "" : opTags.get(0);
+                
+                String realOpPath = operPath.equals("/" + opTag) ? "/" : 
operPath.substring(opTag.length() + 1);
+                userOp.setPath(realOpPath);
                 
                 userOp.setName((String)oper.get("operationId"));
                 List<String> opProduces = 
CastUtils.cast((List<?>)oper.get("produces"));
@@ -146,68 +148,25 @@ public final class SwaggerUtils {
                 if (!userOpParams.isEmpty()) {
                     userOp.setParameters(userOpParams);
                 }
-                userOps.add(userOp);
+                userOpsMap.get(opTag).add(userOp);    
+                
             }
         }
-        ur.setOperations(userOps);
-        return ur;
-    }
-    private static UserResource getUserResourceFromSwagger12(Map<String, 
Object> map) {
-        UserResource ur = new UserResource();
-        String relativePath = (String)map.get("resourcePath");
-        ur.setPath(relativePath == null ? "/" : relativePath);
         
-        List<String> resourceProduces = 
CastUtils.cast((List<?>)map.get("produces"));
-        ur.setProduces(listToString(resourceProduces));
+        List<UserResource> resources = new LinkedList<UserResource>();
         
-        List<String> resourceConsumes = 
CastUtils.cast((List<?>)map.get("consumes"));
-        ur.setConsumes(listToString(resourceConsumes));
-        
-        List<UserOperation> userOps = new LinkedList<UserOperation>();
-        List<Map<String, Object>> apis = 
CastUtils.cast((List<?>)map.get("apis"));
-        for (Map<String, Object> api : apis) {
-            String operPath = (String)api.get("path");
-            if (relativePath != null && operPath.startsWith(relativePath) 
-                && operPath.length() > relativePath.length()) {
-                // relative resource and operation paths overlap in Swagger 1.2
-                operPath = operPath.substring(relativePath.length());
-            }
-            
-            List<Map<String, Object>> operations = 
CastUtils.cast((List<?>)api.get("operations"));
-            for (Map<String, Object> oper : operations) {
-                UserOperation userOp = new UserOperation();
-                userOp.setPath(operPath);
-                userOp.setName((String)oper.get("nickname"));
-                userOp.setVerb((String)oper.get("method"));
-                
-                List<String> opProduces = 
CastUtils.cast((List<?>)oper.get("produces"));
-                userOp.setProduces(listToString(opProduces));
-                
-                List<String> opConsumes = 
CastUtils.cast((List<?>)oper.get("consumes"));
-                userOp.setConsumes(listToString(opConsumes));
-                
-                List<Parameter> userOpParams = new LinkedList<Parameter>(); 
-                List<Map<String, Object>> params = 
CastUtils.cast((List<?>)oper.get("parameters"));
-                for (Map<String, Object> param : params) {
-                    String name = (String)param.get("name");
-                    //"path", "query", "body", "header", "form"
-                    String paramType = (String)param.get("paramType");
-                    ParameterType pType = "body".equals(paramType) 
-                        ? ParameterType.REQUEST_BODY : 
ParameterType.valueOf(paramType.toUpperCase()); 
-                    Parameter userParam = new Parameter(pType, name);
-                    setJavaType(userParam, (String)param.get("type"));
-                    
-                    userOpParams.add(userParam);
-                }   
-                if (!userOpParams.isEmpty()) {
-                    userOp.setParameters(userOpParams);
-                }
-                userOps.add(userOp);
-            }
+        for (Map.Entry<String, List<UserOperation>> entry : 
userOpsMap.entrySet()) {
+            UserResource ur = new UserResource();
+            ur.setPath("/" + entry.getKey());
+            ur.setOperations(entry.getValue());
+            ur.setName(entry.getKey());
+            resources.add(ur);
         }
-        ur.setOperations(userOps);
-        return ur;
+        
+        app.setResources(resources);
+        return app;
     }
+    
     private static void setJavaType(Parameter userParam, String typeName) {
         String javaTypeName = SWAGGER_TYPE_MAP.get(typeName);
         if (javaTypeName != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
 
b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
index 5c3d6e9..4f97feb 100644
--- 
a/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
+++ 
b/rt/rs/description-swagger/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
@@ -18,8 +18,11 @@
  */
 package org.apache.cxf.jaxrs.swagger;
 
+import java.util.Map;
+
 import org.apache.cxf.jaxrs.model.Parameter;
 import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserApplication;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 
@@ -29,46 +32,44 @@ import org.junit.Test;
 public class SwaggerUtilsTest extends Assert {
 
     @Test
-    public void testConvertSwagger12ToUserResource() {
-        UserResource ur = SwaggerUtils.getUserResource("/swagger12.json");
+    public void testConvertSwaggerToUserApp() {
+        UserApplication ap = 
SwaggerUtils.getUserApplication("/swagger20.json");
+        assertNotNull(ap);
+        assertEquals("/services/helloservice", ap.getBasePath());
+        Map<String, UserResource> map = ap.getResourcesAsMap();
+        assertEquals(2, map.size());
+        
+        UserResource ur = map.get("sayHello");
         assertNotNull(ur);
-        assertEquals("/hello", ur.getPath());
+        assertEquals("/sayHello", ur.getPath());
         assertEquals(1, ur.getOperations().size());
         UserOperation op = ur.getOperations().get(0);
-        assertEquals("helloSubject", op.getName());
-        assertEquals("/{subject}", op.getPath());
+        assertEquals("sayHello", op.getName());
+        assertEquals("/{a}", op.getPath());
         assertEquals("GET", op.getVerb());
-        assertEquals(1, op.getParameters().size());
-        Parameter param = op.getParameters().get(0);
-        assertEquals("subject", param.getName());
-        assertEquals(ParameterType.PATH, param.getType());
-        assertEquals(String.class, param.getJavaType());
-    }
-    @Test
-    public void testConvertSwagger20ToUserResource() {
-        UserResource ur = SwaggerUtils.getUserResource("/swagger20.json");
-        assertNotNull(ur);
-        assertEquals("/base", ur.getPath());
-        assertEquals(1, ur.getOperations().size());
-        UserOperation op = ur.getOperations().get(0);
-        assertEquals("postOp", op.getName());
-        assertEquals("/somepath", op.getPath());
-        assertEquals("POST", op.getVerb());
-        assertEquals("application/x-www-form-urlencoded", op.getConsumes());
-        assertEquals("application/json", op.getProduces());
+        assertEquals("text/plain", op.getProduces());
         
-        assertEquals(3, op.getParameters().size());
+        assertEquals(1, op.getParameters().size());
         Parameter param1 = op.getParameters().get(0);
-        assertEquals("userName", param1.getName());
-        assertEquals(ParameterType.FORM, param1.getType());
+        assertEquals("a", param1.getName());
+        assertEquals(ParameterType.PATH, param1.getType());
         assertEquals(String.class, param1.getJavaType());
-        Parameter param2 = op.getParameters().get(1);
-        assertEquals("password", param2.getName());
-        assertEquals(ParameterType.FORM, param2.getType());
+        
+        UserResource ur2 = map.get("sayHello2");
+        assertNotNull(ur2);
+        assertEquals("/sayHello2", ur2.getPath());
+        assertEquals(1, ur2.getOperations().size());
+        UserOperation op2 = ur2.getOperations().get(0);
+        assertEquals("sayHello", op2.getName());
+        assertEquals("/{a}", op2.getPath());
+        assertEquals("GET", op2.getVerb());
+        assertEquals("text/plain", op2.getProduces());
+        
+        assertEquals(1, op2.getParameters().size());
+        Parameter param2 = op.getParameters().get(0);
+        assertEquals("a", param2.getName());
+        assertEquals(ParameterType.PATH, param2.getType());
         assertEquals(String.class, param2.getJavaType());
-        Parameter param3 = op.getParameters().get(2);
-        assertEquals("type", param3.getName());
-        assertEquals(ParameterType.MATRIX, param3.getType());
-        assertEquals(String.class, param3.getJavaType());
+        
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/rt/rs/description-swagger/src/test/resources/swagger12.json
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/test/resources/swagger12.json 
b/rt/rs/description-swagger/src/test/resources/swagger12.json
deleted file mode 100644
index d6b3bab..0000000
--- a/rt/rs/description-swagger/src/test/resources/swagger12.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
-  "swaggerVersion": "1.2",
-  "basePath": "http://localhost:8000/greetings";,
-  "resourcePath": "/hello",
-  "apis": [
-    {
-      "path": "/hello/{subject}",
-      "operations": [
-        {
-          "method": "GET",
-          "summary": "Greet our subject with hello!",
-          "type": "string",
-          "nickname": "helloSubject",
-          "parameters": [
-            {
-              "name": "subject",
-              "description": "The subject to be greeted.",
-              "required": true,
-              "type": "string",
-              "paramType": "path"
-            }
-          ]
-        }
-      ]
-    }
-  ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/rt/rs/description-swagger/src/test/resources/swagger20.json
----------------------------------------------------------------------
diff --git a/rt/rs/description-swagger/src/test/resources/swagger20.json 
b/rt/rs/description-swagger/src/test/resources/swagger20.json
index f8f264d..6fce994 100644
--- a/rt/rs/description-swagger/src/test/resources/swagger20.json
+++ b/rt/rs/description-swagger/src/test/resources/swagger20.json
@@ -1,44 +1,48 @@
 {
-  "swagger": "2.0",
-  "basePath": "/base",
-  "paths": 
-  {
-    "/somepath": 
-    {
-      "post": {
-        "operationId": "postOp",
-        "consumes": [
-          "application/x-www-form-urlencoded"
-        ],
-        "produces": [
-          "application/json"
-        ],
-        "parameters": [
-         {
-          "in": "formData",
-          "name": "userName",
-          "type": "string"
-         }, 
-         {
-          "in": "formData",
-          "name": "password",
-          "type": "string"
-         },
-         {
-          "name": "type",
-          "in": "matrix",
-          "required": true,
-          "type": "string",
-          "enum": [
-            "PROPAGATION",
-            "NOTIFICATION",
-            "SCHEDULED",
-            "SYNCHRONIZATION",
-            "PUSH"
-          ]
-        }
-        ]
-      }
-    }
-  }
-}
\ No newline at end of file
+ "swagger":"2.0",
+ "info": {
+     "description":"The Application",
+     "version":"1.0.0",
+     "title":"Sample REST Application",
+     "contact": {"name":"us...@cxf.apache.org"},
+     "license":{"name":"Apache 2.0 
License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}
+  },
+  
+  basePath":"/services/helloservice",
+  
+  "tags":[
+         {"name":"sayHello2"},
+         {"name":"sayHello"}
+     ],
+     "paths":
+      {
+         "/sayHello/{a}":
+          {
+            "get":
+              {
+               "tags":["sayHello"],
+               "operationId":"sayHello",
+               "produces":
+                   ["text/plain"],
+               "parameters":
+                   [
+                     {"name":"a",
+                      "in":"path",
+                      "required":true,
+                      "type":"string"
+                     }
+                   ],
+               "responses":
+                  {
+                    "200":
+                    {
+                     "description":"successful operation",
+                     "schema":{"type":"string"},
+                     "headers":{}
+                    }
+                  }
+              }
+          },
+         "/sayHello2/{a}":
+          {
+            
"get":{"tags":["sayHello2"],"operationId":"sayHello","produces":["text/plain"],"parameters":[{"name":"a","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful
 operation","schema":{"type":"string"},"headers":{}}}}}}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
index bf758a7..3dfdb99 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/AbstractSwagger2ServiceDescriptionTest.java
@@ -40,6 +40,7 @@ import 
org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.jaxrs.model.Parameter;
 import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.model.UserApplication;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
@@ -105,26 +106,33 @@ public abstract class 
AbstractSwagger2ServiceDescriptionTest extends AbstractBus
         final WebClient client = createWebClient("/swagger.json");
         try {
             String swaggerJson = client.get(String.class);
-            UserResource r = SwaggerUtils.getUserResourceFromJson(swaggerJson);
+            UserApplication ap = 
SwaggerUtils.getUserApplicationFromJson(swaggerJson);
+            assertNotNull(ap);
+            
+            List<UserResource> urs = ap.getResources();
+            assertNotNull(urs);
+            assertEquals(1, urs.size());
+            UserResource r = urs.get(0);
+            assertEquals("/bookstore", r.getPath());
             Map<String, UserOperation> map = r.getOperationsAsMap();
             assertEquals(3, map.size());
             UserOperation getBooksOp = map.get("getBooks");
             assertEquals(HttpMethod.GET, getBooksOp.getVerb());
-            assertEquals("/bookstore", getBooksOp.getPath());
+            assertEquals("/", getBooksOp.getPath());
             assertEquals(MediaType.APPLICATION_JSON, getBooksOp.getProduces());
             List<Parameter> getBooksOpParams = getBooksOp.getParameters();
             assertEquals(1, getBooksOpParams.size());
             assertEquals(ParameterType.QUERY, 
getBooksOpParams.get(0).getType());
             UserOperation getBookOp = map.get("getBook");
             assertEquals(HttpMethod.GET, getBookOp.getVerb());
-            assertEquals("/bookstore/{id}", getBookOp.getPath());
+            assertEquals("/{id}", getBookOp.getPath());
             assertEquals(MediaType.APPLICATION_JSON, getBookOp.getProduces());
             List<Parameter> getBookOpParams = getBookOp.getParameters();
             assertEquals(1, getBookOpParams.size());
             assertEquals(ParameterType.PATH, getBookOpParams.get(0).getType());
             UserOperation deleteOp = map.get("delete");
             assertEquals(HttpMethod.DELETE, deleteOp.getVerb());
-            assertEquals("/bookstore/{id}", deleteOp.getPath());
+            assertEquals("/{id}", deleteOp.getPath());
             List<Parameter> delOpParams = deleteOp.getParameters();
             assertEquals(1, delOpParams.size());
             assertEquals(ParameterType.PATH, delOpParams.get(0).getType());

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
index 492036b..aaada6f 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/description/group1/BookStore.java
@@ -33,10 +33,13 @@ import javax.ws.rs.core.Response;
 
 import org.apache.cxf.systest.jaxrs.Book;
 
+import io.swagger.annotations.Api;
+
 //FIXME swagger-jaxrs 1.5.3 can't handle a self-recursive sub resource like 
Book. so hide Book for now
 //import org.apache.cxf.systest.jaxrs.Book;
 
-@Path("/bookstore") 
+@Path("/bookstore")
+@Api("/bookstore")
 public class BookStore {
     @Produces({ MediaType.APPLICATION_JSON })
     @GET

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
 
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
deleted file mode 100644
index a1317de..0000000
--- 
a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-json.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"The 
Application","version":"1.0.0","title":"Sample REST 
Application","contact":{"name":"us...@cxf.apache.org"},"license":{"name":"Apache
 2.0 
License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"host":"localhost:%s","basePath":"/","tags":[{"name":"bookstore"}],"paths":{"/bookstore":{"get":{"tags":["bookstore"],"summary":"Get
 books","description":"Get 
books","operationId":"getBooks","produces":["application/json"],"parameters":[{"name":"page","in":"query","description":"Page
 to 
fetch","required":true,"type":"integer","default":1,"format":"int32"}],"responses":{"200":{"description":"successful
 
operation","schema":{"type":"array","items":{"$ref":"#/definitions/Book"}}}}}},"/bookstore/{id}":{"get":{"tags":["bookstore"],"summary":"Get
 book by Id","description":"Get book by 
Id","operationId":"getBook","produces":["application/json"],"parameters":[{"name":"id","in":"path","description":"id","required":true,"type":"integer","format":"int
 64"}],"responses":{"200":{"description":"successful 
operation","schema":{"$ref":"#/definitions/Book"}}}},"delete":{"tags":["bookstore"],"summary":"Delete
 book","description":"Delete 
book","operationId":"delete","parameters":[{"name":"id","in":"path","description":"id","required":true,"type":"string"}],"responses":{"default":{"description":"successful
 
operation"}}}}},"definitions":{"Book":{"type":"object","properties":{"name":{"type":"string"},"id":{"type":"integer","format":"int64"}},"xml":{"name":"Book"}}}}

http://git-wip-us.apache.org/repos/asf/cxf/blob/bdc67fbc/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-noano-json.txt
----------------------------------------------------------------------
diff --git 
a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-noano-json.txt
 
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-noano-json.txt
deleted file mode 100644
index 1a92fcf..0000000
--- 
a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/description/swagger2-noano-json.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"swagger":"2.0","info":{"description":"The 
Application","version":"1.0.0","title":"Sample REST 
Application","contact":{"name":"us...@cxf.apache.org"},"license":{"name":"Apache
 2.0 
License","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"host":"localhost:%s","basePath":"/","paths":{"/bookstore/name/{id}":{"get":{"operationId":"getBookName","parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"successful
 
operation","schema":{"type":"string"},"headers":{}}}}},"/bookstore/names":{"get":{"operationId":"getBookNames","parameters":[{"name":"page","in":"query","required":false,"type":"integer","default":1,"format":"int32"}],"responses":{"default":{"description":"successful
 
operation"}}}},"/bookstore/{id}":{"delete":{"operationId":"delete","parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"default":{"description":"successful
 operation"}}}}}}

Reply via email to