cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-6760] Moving Swagger code into its own module
Date Tue, 05 Jul 2016 09:40:16 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes c8e00d415 -> 33c6109b3


http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
deleted file mode 100644
index 2438458..0000000
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerUtils.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs.swagger;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-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.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.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-
-public final class SwaggerUtils {
-    private static final Logger LOG = LogUtils.getL7dLogger(ResourceUtils.class);
-    private static final Map<String, String> SWAGGER_TYPE_MAP; 
-    static {
-        SWAGGER_TYPE_MAP = new HashMap<String, String>();
-        SWAGGER_TYPE_MAP.put("string", "String");
-        SWAGGER_TYPE_MAP.put("integer", "long");
-        SWAGGER_TYPE_MAP.put("float", "float");
-        SWAGGER_TYPE_MAP.put("double", "double");
-        SWAGGER_TYPE_MAP.put("int", "int");
-        SWAGGER_TYPE_MAP.put("long", "long");
-        SWAGGER_TYPE_MAP.put("byte", "byte");
-        SWAGGER_TYPE_MAP.put("boolean", "boolean");
-        SWAGGER_TYPE_MAP.put("date", "java.util.Date");
-        SWAGGER_TYPE_MAP.put("dateTime", "java.util.Date");
-        SWAGGER_TYPE_MAP.put("File", "java.io.InputStream");
-        SWAGGER_TYPE_MAP.put("file", "java.io.InputStream");
-    }
-    private SwaggerUtils() {
-        
-    }
-    public static UserResource getUserResource(String loc) {
-        return getUserResource(loc, BusFactory.getThreadDefaultBus());
-    }
-    public static UserResource getUserResource(String loc, Bus bus) {
-        try {
-            InputStream is = ResourceUtils.getResourceStream(loc, bus);
-            if (is == null) {
-                return null;
-            }
-            return getUserResourceFromJson(IOUtils.readStringFromStream(is));
-        } catch (Exception ex) {
-            LOG.warning("Problem with processing a user model at " + loc);
-        }
-        return null;
-    }
-    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) {
-        JsonMapObjectReaderWriter reader = new JsonMapObjectReaderWriter();
-        Map<String, Object> map = reader.fromJson(json);
-        
-        if (map.containsKey("swaggerVersion")) {
-            return getUserResourceFromSwagger12(map);
-        } else {
-            return getUserResourceFromSwagger20(map);
-        }
-        
-    }
-    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());
-                
-                userOp.setName((String)oper.get("operationId"));
-                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");
-                    //"query", "header", "path", "formData" or "body"
-                    String paramType = (String)param.get("in");
-                    ParameterType pType = "body".equals(paramType) ? ParameterType.REQUEST_BODY

-                        : "formData".equals(paramType) 
-                        ? ParameterType.FORM : 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);
-            }
-        }
-        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<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);
-            }
-        }
-        ur.setOperations(userOps);
-        return ur;
-    }
-    private static void setJavaType(Parameter userParam, String typeName) {
-        String javaTypeName = SWAGGER_TYPE_MAP.get(typeName);
-        if (javaTypeName != null) {
-            try {
-                userParam.setJavaType(ClassLoaderUtils.loadClass(javaTypeName, SwaggerUtils.class));
-            } catch (Throwable t) {
-                // ignore - can be a reference to a JSON model class, etc
-            }
-        }
-        
-    }
-    private static String listToString(List<String> list) {
-        if (list != null) {
-            StringBuilder sb = new StringBuilder();
-            for (String s : list) {
-                if (sb.length() > 0) {
-                    sb.append(',');
-                }
-                sb.append(s);
-            }
-            return sb.toString();
-        } else {
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
b/rt/rs/description/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
deleted file mode 100644
index 9803485..0000000
--- a/rt/rs/description/src/main/resources/META-INF/services/io.swagger.jaxrs.ext.SwaggerExtension
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.cxf.jaxrs.swagger.JaxRs2Extension

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/doc/JavaDocProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/doc/JavaDocProviderTest.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/doc/JavaDocProviderTest.java
deleted file mode 100644
index 94319e4..0000000
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/doc/JavaDocProviderTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs.model.doc;
-
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.wadl.petstore.PetStore;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class JavaDocProviderTest extends Assert {
-
-    @Test
-    public void testJava6Docs() throws Exception {
-        doTestJavaDocs("classpath:/javadocs/pet-store-javadoc16.jar", "1.6");
-    }
-    
-    @Test
-    public void testJava7Docs() throws Exception {
-        doTestJavaDocs("classpath:/javadocs/pet-store-javadoc17.jar", "1.7");
-    }
-    @Test
-    public void testJava8Docs() throws Exception {
-        doTestJavaDocs("classpath:/javadocs/pet-store-javadoc18.jar", "1.8");
-    }
-    
-    private void doTestJavaDocs(String path, String version) throws Exception {
-        JavaDocProvider p = new JavaDocProvider(path);
-        p.setJavaDocsBuiltByVersion(version);
-        ClassResourceInfo cri = 
-            ResourceUtils.createClassResourceInfo(PetStore.class, PetStore.class, true, true);
-        String classDoc = p.getClassDoc(cri);
-        assertEquals("The Pet Store", classDoc);
-        
-        boolean getStatus1Tested = false;
-        boolean getStatus2Tested = false;
-        boolean getStatus3Tested = false;
-        boolean noDocsTested = false;
-        for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos())
{
-            if ("getStatus1Param".equals(ori.getMethodToInvoke().getName())) {
-                testGetStatus1JavaDocs(p, ori);
-                getStatus1Tested = true;
-            } else if ("getStatus2Params".equals(ori.getMethodToInvoke().getName())) {
-                testGetStatus2JavaDocs(p, ori);
-                getStatus2Tested = true;
-            } else if ("getStatus3Params".equals(ori.getMethodToInvoke().getName())) {
-                testGetStatus3JavaDocs(p, ori);
-                getStatus3Tested = true;
-            } else if ("getBaseStatus".equals(ori.getMethodToInvoke().getName())) {
-                testOperWithNoJavaDocs(p, ori);
-                noDocsTested = true;
-            }
-        }
-        assertTrue(getStatus1Tested);
-        assertTrue(getStatus2Tested);
-        assertTrue(getStatus3Tested);
-        assertTrue(noDocsTested);
-        assertTrue(true);
-    }
-
-    private void testOperWithNoJavaDocs(JavaDocProvider p, OperationResourceInfo ori) {
-        assertEquals(0, ori.getParameters().size());
-        assertEquals("Return Pet Status with no params", p.getMethodDoc(ori));
-        assertEquals("status", p.getMethodResponseDoc(ori));
-    }
-    
-    private void testGetStatus1JavaDocs(JavaDocProvider p, OperationResourceInfo ori) {
-        assertEquals("Return Pet Status With 1 Param", p.getMethodDoc(ori));
-        assertEquals(1, ori.getParameters().size());
-        assertEquals("status", p.getMethodResponseDoc(ori));
-        assertEquals("the pet id", p.getMethodParameterDoc(ori, 0));
-    }
-    private void testGetStatus2JavaDocs(JavaDocProvider p, OperationResourceInfo ori) {
-        assertEquals("Return Pet Status with 2 params", p.getMethodDoc(ori));
-        assertEquals(2, ori.getParameters().size());
-        assertEquals("status", p.getMethodResponseDoc(ori));
-        assertEquals("the pet id", p.getMethodParameterDoc(ori, 0));
-        assertEquals("the query", p.getMethodParameterDoc(ori, 1));
-    }
-    private void testGetStatus3JavaDocs(JavaDocProvider p, OperationResourceInfo ori) {
-        assertEquals("Return Pet Status With 3 Params", p.getMethodDoc(ori));
-        assertEquals(3, ori.getParameters().size());
-        assertEquals("status", p.getMethodResponseDoc(ori));
-        assertEquals("the pet id", p.getMethodParameterDoc(ori, 0));
-        assertEquals("the query", p.getMethodParameterDoc(ori, 1));
-        assertEquals("the query2", p.getMethodParameterDoc(ori, 2));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
deleted file mode 100644
index c87b041..0000000
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/Swagger2FeatureTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jaxrs.swagger;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- */
-public class Swagger2FeatureTest extends Assert {
-    @Test
-    public void testSetBasePathByAddress() {
-        Swagger2Feature f = new Swagger2Feature();
-
-        f.setBasePathByAddress("http://localhost:8080/foo");
-        assertEquals("/foo", f.getBasePath());
-        assertEquals("localhost:8080", f.getHost());
-        unsetBasePath(f);
-
-        f.setBasePathByAddress("http://localhost/foo");
-        assertEquals("/foo", f.getBasePath());
-        assertEquals("localhost", f.getHost());
-        unsetBasePath(f);
-
-        f.setBasePathByAddress("/foo");
-        assertEquals("/foo", f.getBasePath());
-        assertNull(f.getHost());
-        unsetBasePath(f);
-    }
-
-    private static void unsetBasePath(Swagger2Feature f) {
-        f.setBasePath(null);
-        f.setHost(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerFeatureTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerFeatureTest.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerFeatureTest.java
deleted file mode 100644
index a1922d5..0000000
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerFeatureTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.jaxrs.swagger;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- */
-public class SwaggerFeatureTest extends Assert {
-    @Test
-    public void testSetBasePathByAddress() {
-        SwaggerFeature f = new SwaggerFeature();
-
-        f.setBasePathByAddress("http://localhost:8080/foo");
-        assertEquals("http://localhost:8080/foo", f.getBasePath());
-        unsetBasePath(f);
-
-        f.setBasePathByAddress("/foo");
-        assertEquals("/foo", f.getBasePath());
-        unsetBasePath(f);
-    }
-
-    private static void unsetBasePath(SwaggerFeature f) {
-        f.setBasePath(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
deleted file mode 100644
index 5c3d6e9..0000000
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/swagger/SwaggerUtilsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.jaxrs.swagger;
-
-import org.apache.cxf.jaxrs.model.Parameter;
-import org.apache.cxf.jaxrs.model.ParameterType;
-import org.apache.cxf.jaxrs.model.UserOperation;
-import org.apache.cxf.jaxrs.model.UserResource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SwaggerUtilsTest extends Assert {
-
-    @Test
-    public void testConvertSwagger12ToUserResource() {
-        UserResource ur = SwaggerUtils.getUserResource("/swagger12.json");
-        assertNotNull(ur);
-        assertEquals("/hello", ur.getPath());
-        assertEquals(1, ur.getOperations().size());
-        UserOperation op = ur.getOperations().get(0);
-        assertEquals("helloSubject", op.getName());
-        assertEquals("/{subject}", 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(3, op.getParameters().size());
-        Parameter param1 = op.getParameters().get(0);
-        assertEquals("userName", param1.getName());
-        assertEquals(ParameterType.FORM, param1.getType());
-        assertEquals(String.class, param1.getJavaType());
-        Parameter param2 = op.getParameters().get(1);
-        assertEquals("password", param2.getName());
-        assertEquals(ParameterType.FORM, 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/33c6109b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc16.jar
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc16.jar b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc16.jar
deleted file mode 100644
index b7f2cb6..0000000
Binary files a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc16.jar and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc17.jar
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc17.jar b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc17.jar
deleted file mode 100644
index d49a58d..0000000
Binary files a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc17.jar and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc18.jar
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc18.jar b/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc18.jar
deleted file mode 100644
index 24a8c63..0000000
Binary files a/rt/rs/description/src/test/resources/javadocs/pet-store-javadoc18.jar and /dev/null
differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/description/src/test/resources/swagger12.json
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/resources/swagger12.json b/rt/rs/description/src/test/resources/swagger12.json
deleted file mode 100644
index d6b3bab..0000000
--- a/rt/rs/description/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/33c6109b/rt/rs/description/src/test/resources/swagger20.json
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/resources/swagger20.json b/rt/rs/description/src/test/resources/swagger20.json
deleted file mode 100644
index f8f264d..0000000
--- a/rt/rs/description/src/test/resources/swagger20.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
-  "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

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/rt/rs/pom.xml
----------------------------------------------------------------------
diff --git a/rt/rs/pom.xml b/rt/rs/pom.xml
index 0a835ec..5c68208 100644
--- a/rt/rs/pom.xml
+++ b/rt/rs/pom.xml
@@ -33,6 +33,7 @@
         <module>client</module>
         <module>http-sci</module>
         <module>description</module>
+        <module>description-swagger</module>
         <module>extensions/json-basic</module>
         <module>extensions/providers</module>
         <module>extensions/search</module>

http://git-wip-us.apache.org/repos/asf/cxf/blob/33c6109b/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 84567ed..dfacd0a 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -38,28 +38,6 @@
 
     </properties>
     <dependencies>
-        <!-- for swagger 1.2 tests -->
-        <dependency>
-            <groupId>com.wordnik</groupId>
-            <artifactId>swagger-jaxrs_2.10</artifactId>
-            <exclusions>
-                <exclusion>
-                     <groupId>javax.ws.rs</groupId>
-                     <artifactId>jsr311-api</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <!-- for swagger 2.0 tests -->
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-jaxrs</artifactId>
-            <exclusions>
-                <exclusion>
-                     <groupId>javax.ws.rs</groupId>
-                     <artifactId>jsr311-api</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>javassist</groupId>
             <artifactId>javassist</artifactId>
@@ -143,6 +121,25 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <!-- Swagger 2 dep is strong, 1.2 - optional -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- For Swagger 1.2 tests -->
+        <dependency>
+            <groupId>com.wordnik</groupId>
+            <artifactId>swagger-jaxrs_2.10</artifactId>
+            <exclusions>
+                <exclusion>
+                     <groupId>javax.ws.rs</groupId>
+                     <artifactId>jsr311-api</artifactId>
+                </exclusion>
+            </exclusions>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>org.apache.ant</groupId>
             <artifactId>ant</artifactId>


Mime
View raw message