cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [6/6] cxf git commit: Support multiple URLs for javadocs
Date Wed, 02 Dec 2015 14:59:20 GMT
Support multiple URLs for javadocs


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

Branch: refs/heads/3.0.x-fixes
Commit: ec399a6a7e838614ffdd8d2531dd21fdf29ff51c
Parents: df45376
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Wed Dec 2 15:58:57 2015 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Wed Dec 2 15:58:57 2015 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/model/doc/JavaDocProvider.java    | 47 +++++++----
 .../cxf/jaxrs/model/wadl/WadlGenerator.java     | 85 +++++++++++---------
 .../cxf/jaxrs/swagger/Swagger2Feature.java      | 12 ++-
 .../cxf/jaxrs/swagger/Swagger2Serializers.java  | 12 +--
 4 files changed, 94 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ec399a6a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/doc/JavaDocProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/doc/JavaDocProvider.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/doc/JavaDocProvider.java
index b3fe34a..942eb04 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/doc/JavaDocProvider.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/doc/JavaDocProvider.java
@@ -44,22 +44,35 @@ public class JavaDocProvider implements DocumentationProvider {
     public static final double JAVA_VERSION_18 = 1.8D;
 
     private ClassLoader javaDocLoader;
-    private ConcurrentHashMap<String, ClassDocs> docs = new ConcurrentHashMap<String,
ClassDocs>();
+    private final ConcurrentHashMap<String, ClassDocs> docs = new ConcurrentHashMap<String,
ClassDocs>();
     private double javaDocsBuiltByVersion = JAVA_VERSION;
     
-    public JavaDocProvider(URL javaDocUrl) {
-        if (javaDocUrl == null) {
-            throw new IllegalArgumentException("URL is null");
+    public JavaDocProvider(URL... javaDocUrls) {
+        if (javaDocUrls == null) {
+            throw new IllegalArgumentException("URL are null");
         }
-        javaDocLoader = new URLClassLoader(new URL[]{javaDocUrl});
+        
+        javaDocLoader = new URLClassLoader(javaDocUrls);
     }
     
     public JavaDocProvider(String path) throws Exception {
         this(BusFactory.getDefaultBus(), path);
     }
     
-    public JavaDocProvider(Bus bus, String path) throws Exception {
-        this(ResourceUtils.getResourceURL(path, bus));
+    public JavaDocProvider(String... paths) throws Exception {
+        this(BusFactory.getDefaultBus(), paths == null ? null : paths);
+    }
+    
+    public JavaDocProvider(Bus bus, String... paths) throws Exception {
+        if (paths == null) {
+            throw new IllegalArgumentException("paths are null");
+        }
+
+        URL[] javaDocUrls = new URL[paths.length];
+        for (int i = 0; i < paths.length; i++) {
+            javaDocUrls[i] = ResourceUtils.getResourceURL(paths[i], bus);
+        }
+        javaDocLoader = new URLClassLoader(javaDocUrls);
     }
     
     private static double getVersion() {
@@ -71,6 +84,7 @@ public class JavaDocProvider implements DocumentationProvider {
         }
     }
     
+    @Override
     public String getClassDoc(ClassResourceInfo cri) {
         try {
             ClassDocs doc = getClassDocInternal(cri.getServiceClass());
@@ -84,6 +98,7 @@ public class JavaDocProvider implements DocumentationProvider {
         return null;
     }
     
+    @Override
     public String getMethodDoc(OperationResourceInfo ori) {
         try {
             MethodDocs doc = getOperationDocInternal(ori);
@@ -97,6 +112,7 @@ public class JavaDocProvider implements DocumentationProvider {
         return null;
     }
     
+    @Override
     public String getMethodResponseDoc(OperationResourceInfo ori) {
         try {
             MethodDocs doc = getOperationDocInternal(ori);
@@ -110,6 +126,7 @@ public class JavaDocProvider implements DocumentationProvider {
         return null;
     }
     
+    @Override
     public String getMethodParameterDoc(OperationResourceInfo ori, int paramIndex) {
         try {
             MethodDocs doc = getOperationDocInternal(ori);
@@ -228,7 +245,7 @@ public class JavaDocProvider implements DocumentationProvider {
                     
                     int codeIndex = paramString.indexOf(codeTag);
                     while (codeIndex != -1) {
-                        int next = paramString.indexOf("<", codeIndex + 7);
+                        int next = paramString.indexOf('<', codeIndex + 7);
                         if (next == -1) {
                             next = paramString.length();
                         }
@@ -261,7 +278,7 @@ public class JavaDocProvider implements DocumentationProvider {
         if (tagIndex != -1) {
             int notAfterIndex = doc.indexOf(notAfterTag, index);
             if (notAfterIndex == -1 || notAfterIndex > tagIndex) {
-                int nextIndex = doc.indexOf("<", tagIndex + tag.length());
+                int nextIndex = doc.indexOf('<', tagIndex + tag.length());
                 if (nextIndex != -1) {
                     return doc.substring(tagIndex + tag.length(), nextIndex).trim();
                 }
@@ -313,9 +330,9 @@ public class JavaDocProvider implements DocumentationProvider {
     }
     
     private static class ClassDocs {
-        private String classDoc;
-        private String classInfo;
-        private ConcurrentHashMap<Method, MethodDocs> mdocs = new ConcurrentHashMap<Method,
MethodDocs>(); 
+        private final String classDoc;
+        private final String classInfo;
+        private final ConcurrentHashMap<Method, MethodDocs> mdocs = new ConcurrentHashMap<Method,
MethodDocs>(); 
         public ClassDocs(String classDoc, String classInfo) {
             this.classDoc = classDoc;
             this.classInfo = classInfo;
@@ -339,9 +356,9 @@ public class JavaDocProvider implements DocumentationProvider {
     }
     
     private static class MethodDocs {
-        private String methodInfo;
-        private List<String> paramInfo = new LinkedList<String>();
-        private String responseInfo;
+        private final String methodInfo;
+        private final List<String> paramInfo;
+        private final String responseInfo;
         public MethodDocs(String methodInfo, List<String> paramInfo, String responseInfo)
{
             this.methodInfo = methodInfo;
             this.paramInfo = paramInfo;

http://git-wip-us.apache.org/repos/asf/cxf/blob/ec399a6a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
index 0ed2c14..b43d793 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
@@ -30,6 +30,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -169,8 +170,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     private boolean checkAbsolutePathSlash;
     private boolean keepRelativeDocLinks;
     private boolean usePathParamsToCompareOperations = true;
-    
-    
+        
     private boolean ignoreMessageWriters = true;
     private boolean ignoreRequests;
     private boolean convertResourcesToDOM = true;
@@ -186,14 +186,12 @@ public class WadlGenerator implements ContainerRequestFilter {
     private String applicationTitle;
     private String nsPrefix = DEFAULT_NS_PREFIX;
     private MediaType defaultWadlResponseMediaType = MediaType.APPLICATION_XML_TYPE;
-    private MediaType defaultRepMediaType = MediaType.WILDCARD_TYPE;
+    private final MediaType defaultRepMediaType = MediaType.WILDCARD_TYPE;
     private String stylesheetReference;
     private boolean applyStylesheetLocally;
     private Bus bus;
-    private List<DocumentationProvider> docProviders = new LinkedList<DocumentationProvider>();
-    private ResourceIdGenerator idGenerator;     
-    
-    
+    private final List<DocumentationProvider> docProviders = new LinkedList<DocumentationProvider>();
+    private ResourceIdGenerator idGenerator;             
     
     public WadlGenerator() {
     }
@@ -202,8 +200,8 @@ public class WadlGenerator implements ContainerRequestFilter {
         this.bus = bus;
     }
 
+    @Override
     public void filter(ContainerRequestContext context) {
-
         Message m = JAXRSUtils.getCurrentMessage();
         doFilter(context, m);
     }
@@ -271,7 +269,7 @@ public class WadlGenerator implements ContainerRequestFilter {
                                        UriInfo ui) {
         StringBuilder sbMain = new StringBuilder();
         if (!isJson && stylesheetReference != null && !applyStylesheetLocally)
{
-            sbMain.append("<?xml-stylesheet " + getStylesheetInstructionData(baseURI)
+ "?>");
+            sbMain.append("<?xml-stylesheet ").append(getStylesheetInstructionData(baseURI)).append("?>");
         }
         sbMain.append("<application");
         if (!isJson) {
@@ -447,7 +445,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     }
 
     protected String getPath(String path) {
-        String thePath = null;
+        String thePath;
         if (ignoreForwardSlash && path.startsWith("/") && path.length() >
0) {
             thePath = path.substring(1);
         } else {
@@ -580,7 +578,7 @@ public class WadlGenerator implements ContainerRequestFilter {
         if (!handleDocs(anns, sb, DocTarget.METHOD, true, isJson)) {
             handleOperJavaDocs(ori, sb);
         }
-        if (getMethod(ori).getParameterTypes().length != 0 || classParams.size() != 0) {
+        if (getMethod(ori).getParameterTypes().length != 0 || !classParams.isEmpty()) {
             startMethodRequestTag(sb, ori);
             handleDocs(anns, sb, DocTarget.REQUEST, false, isJson);
 
@@ -941,12 +939,12 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private void setEnumOptions(StringBuilder sb, Class<?> enumClass) {
         try {
-            Method m = enumClass.getMethod("values", new Class[] {});
+            Method m = enumClass.getMethod("values", new Class<?>[] {});
             Object[] values = (Object[])m.invoke(null, new Object[] {});
-            m = enumClass.getMethod("toString", new Class[] {});
+            m = enumClass.getMethod("toString", new Class<?>[] {});
             for (Object o : values) {
                 String str = (String)m.invoke(o, new Object[] {});
-                sb.append("<option value=\"" + str + "\"/>");
+                sb.append("<option value=\"").append(str).append("\"/>");
             }
 
         } catch (Throwable ex) {
@@ -968,12 +966,12 @@ public class WadlGenerator implements ContainerRequestFilter {
             sb.append(">");
             if (docAnnAvailable) {
                 handleDocs(anns, sb, category, allowDefault, isJson);
-            } else if (category == DocTarget.RETURN) {
+            } else if (DocTarget.RETURN.equals(category)) {
                 handleOperResponseJavaDocs(ori, sb);
-            } else if (category == DocTarget.PARAM) {
+            } else if (DocTarget.PARAM.equals(category)) {
                 handleOperParamJavaDocs(ori, paramIndex, sb);
             }
-            sb.append("</" + elementName + ">");
+            sb.append("</").append(elementName).append(">");
         } else {
             sb.append("/>");
         }
@@ -1013,7 +1011,7 @@ public class WadlGenerator implements ContainerRequestFilter {
             String docCategory;
             Annotation[] anns;
             int inParamIndex = -1;
-            Type genericType = null;
+            Type genericType;
             if (inbound) {
                 inParamIndex = getRequestBodyParam(ori).getIndex();
                 anns = opMethod.getParameterAnnotations()[inParamIndex];
@@ -1036,7 +1034,7 @@ public class WadlGenerator implements ContainerRequestFilter {
                 sb.append("</representation>");
             } else {
                 boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
-                Class<?> theActualType = null;
+                Class<?> theActualType;
                 if (isCollection) {
                     theActualType = InjectionUtils.getActualType(genericType);
                 } else {
@@ -1106,6 +1104,7 @@ public class WadlGenerator implements ContainerRequestFilter {
         List<OperationResourceInfo> opsWithSamePath = new LinkedList<OperationResourceInfo>(ops);
         Collections.sort(opsWithSamePath, new Comparator<OperationResourceInfo>() {
 
+            @Override
             public int compare(OperationResourceInfo op1, OperationResourceInfo op2) {
                 boolean sub1 = op1.getHttpMethod() == null;
                 boolean sub2 = op2.getHttpMethod() == null;
@@ -1206,7 +1205,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     }
     private Response finalizeExistingWadlResponse(Document wadlDoc, Message m, UriInfo ui,
MediaType mt) 
         throws Exception {
-        Object entity = null;
+        Object entity;
         if (stylesheetReference != null) {
             if (!applyStylesheetLocally) {
                 ProcessingInstruction pi = wadlDoc.createProcessingInstruction("xml-stylesheet",

@@ -1246,7 +1245,7 @@ public class WadlGenerator implements ContainerRequestFilter {
         try {
             String loc = docLocationMap.get(href);
             if (loc != null) {
-                int fragmentIndex = loc.lastIndexOf("#");
+                int fragmentIndex = loc.lastIndexOf('#');
                 if (fragmentIndex != -1) {
                     loc = loc.substring(0, fragmentIndex);
                 }
@@ -1307,7 +1306,7 @@ public class WadlGenerator implements ContainerRequestFilter {
             String href = element.getAttribute(attrName);
             String originalRef = href;
             if (!StringUtils.isEmpty(href) && !href.startsWith("#")) {
-                int fragmentIndex = href.lastIndexOf("#");
+                int fragmentIndex = href.lastIndexOf('#');
                 String fragment = null;
                 if (fragmentIndex != -1) {
                     fragment = href.substring(fragmentIndex + 1);
@@ -1342,7 +1341,7 @@ public class WadlGenerator implements ContainerRequestFilter {
                 clsMap.put(type, qname);
             } else {
                 XMLName name = AnnotationUtils.getAnnotation(annotations, XMLName.class);
-                String localPart = null;
+                String localPart;
                 if (name != null) {
                     localPart = JAXRSUtils.convertStringToQName(name.value()).getLocalPart();
                 } else {
@@ -1355,8 +1354,7 @@ public class WadlGenerator implements ContainerRequestFilter {
     }
 
     private void writeQName(StringBuilder sb, QName qname) {
-        sb.append(" element=\"").append(qname.getPrefix()).append(':').append(qname.getLocalPart())
-            .append("\"");
+        sb.append(" element=\"").append(qname.getPrefix()).append(':').append(qname.getLocalPart()).append("\"");
     }
 
     private boolean isXmlRoot(Class<?> cls) {
@@ -1494,7 +1492,6 @@ public class WadlGenerator implements ContainerRequestFilter {
     }
 
     private QName getJaxbQName(String name, String namespace, Class<?> type, Map<Class<?>,
QName> clsMap) {
-
         QName qname = getQNameFromParts(name, namespace, type, clsMap);
         if (qname != null) {
             return qname;
@@ -1509,7 +1506,6 @@ public class WadlGenerator implements ContainerRequestFilter {
     }
     
     private QName getJaxbQName(JAXBContextProxy jaxbProxy, Class<?> type, Map<Class<?>,
QName> clsMap) {
-
         XmlRootElement root = type.getAnnotation(XmlRootElement.class);
         if (root != null) {
             return getJaxbQName(root.name(), root.namespace(), type, clsMap);
@@ -1671,7 +1667,7 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private void handleApplicationDocs(StringBuilder sbApp) {
         if (applicationTitle != null) {
-            sbApp.append("<doc title=\"" + xmlEncodeIfNeeded(applicationTitle) + "\"/>");
+            sbApp.append("<doc title=\"").append(xmlEncodeIfNeeded(applicationTitle)).append("\"/>");
         }
     }
 
@@ -1728,16 +1724,16 @@ public class WadlGenerator implements ContainerRequestFilter {
 
                 sb.append("<doc");
                 if (!isJson && d.lang().length() > 0) {
-                    sb.append(" xml:lang=\"" + d.lang() + "\"");
+                    sb.append(" xml:lang=\"").append(d.lang()).append("\"");
                 }
                 if (d.title().length() > 0) {
-                    sb.append(" title=\"" + xmlEncodeIfNeeded(d.title()) + "\"");
+                    sb.append(" title=\"").append(xmlEncodeIfNeeded(d.title())).append("\"");
                 }
                 sb.append(">");
                 if (d.value().length() > 0) {
                     sb.append(xmlEncodeIfNeeded(d.value()));
                 } else if (d.docuri().length() > 0) {
-                    InputStream is = null;
+                    InputStream is;
                     if (d.docuri().startsWith(CLASSPATH_PREFIX)) {
                         String path = d.docuri().substring(CLASSPATH_PREFIX.length());
                         is = ResourceUtils.getClasspathResourceStream(path, SchemaHandler.class,
@@ -1948,6 +1944,7 @@ public class WadlGenerator implements ContainerRequestFilter {
 
         }
 
+        @Override
         public void write(StringBuilder sb) {
             for (String s : theSchemas) {
                 sb.append(s);
@@ -1957,12 +1954,13 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private class SchemaCollectionWriter implements SchemaWriter {
 
-        private SchemaCollection coll;
+        private final SchemaCollection coll;
 
         public SchemaCollectionWriter(SchemaCollection coll) {
             this.coll = coll;
         }
 
+        @Override
         public void write(StringBuilder sb) {
             for (XmlSchema xs : coll.getXmlSchemas()) {
                 if (xs.getItems().isEmpty() || Constants.URI_2001_SCHEMA_XSD.equals(xs.getTargetNamespace()))
{
@@ -1977,14 +1975,15 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private class ExternalSchemaWriter implements SchemaWriter {
 
-        private List<URI> links;
-        private UriInfo uriInfo;
+        private final List<URI> links;
+        private final UriInfo uriInfo;
 
         public ExternalSchemaWriter(List<URI> links, UriInfo ui) {
             this.links = links;
             this.uriInfo = ui;
         }
 
+        @Override
         public void write(StringBuilder sb) {
             for (URI link : links) {
                 try {
@@ -2001,12 +2000,13 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private class JaxbContextQNameResolver implements ElementQNameResolver {
 
-        private JAXBContextProxy proxy;
+        private final JAXBContextProxy proxy;
         
         public JaxbContextQNameResolver(JAXBContextProxy proxy) {
             this.proxy = proxy;
         }
 
+        @Override
         public QName resolve(Class<?> type, Annotation[] annotations, Map<Class<?>,
QName> clsMap) {
             QName qname = WadlGenerator.this.getJaxbQName(proxy, type, clsMap);
             if (qname == null && supportJaxbXmlType) {
@@ -2030,6 +2030,7 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private class XMLNameQNameResolver implements ElementQNameResolver {
 
+        @Override
         public QName resolve(Class<?> type, Annotation[] annotations, Map<Class<?>,
QName> clsMap) {
             XMLName name = AnnotationUtils.getAnnotation(annotations, XMLName.class);
             if (name == null) {
@@ -2050,12 +2051,13 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private class SchemaQNameResolver implements ElementQNameResolver {
 
-        private Map<String, List<String>> map;
+        private final Map<String, List<String>> map;
 
         public SchemaQNameResolver(Map<String, List<String>> map) {
             this.map = map;
         }
 
+        @Override
         public QName resolve(Class<?> type, Annotation[] annotations, Map<Class<?>,
QName> clsMap) {
             String name = type.getSimpleName();
             for (Map.Entry<String, List<String>> entry : map.entrySet()) {
@@ -2157,6 +2159,14 @@ public class WadlGenerator implements ContainerRequestFilter {
         setDocumentationProvider(new JavaDocProvider(bus == null ? BusFactory.getDefaultBus()
: bus, path));
     }
     
+    public void setJavaDocPaths(String... paths) throws Exception {
+        setDocumentationProvider(new JavaDocProvider(bus == null ? BusFactory.getDefaultBus()
: bus, paths));
+    }
+
+    public void setJavaDocURLs(final URL[] javaDocURLs) {
+        setDocumentationProvider(new JavaDocProvider(javaDocURLs));
+    }
+
     public void setDocumentationProvider(DocumentationProvider p) {
         docProviders.add(p);
     }
@@ -2197,13 +2207,14 @@ public class WadlGenerator implements ContainerRequestFilter {
 
     private static class SchemaConverter extends DelegatingXMLStreamWriter {
         private static final String SCHEMA_LOCATION = "schemaLocation";
-        private Map<String, String> locsMap;
+        private final Map<String, String> locsMap;
 
         public SchemaConverter(XMLStreamWriter writer, Map<String, String> locsMap)
{
             super(writer);
             this.locsMap = locsMap;
         }
 
+        @Override
         public void writeAttribute(String local, String value) throws XMLStreamException
{
             if (SCHEMA_LOCATION.equals(local) && locsMap.containsKey(value)) {
                 value = locsMap.get(value);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ec399a6a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
index 0824fa8..701701b 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Feature.java
@@ -20,6 +20,7 @@ package org.apache.cxf.jaxrs.swagger;
 
 import java.io.IOException;
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashSet;
@@ -34,7 +35,6 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
@@ -160,7 +160,15 @@ public class Swagger2Feature extends AbstractSwaggerFeature {
     }
 
     public void setJavaDocPath(final String javaDocPath) throws Exception {
-        this.javadocProvider = new JavaDocProvider(BusFactory.getDefaultBus(), javaDocPath);
+        this.javadocProvider = new JavaDocProvider(javaDocPath);
+    }
+
+    public void setJavaDocPaths(final String... javaDocPaths) throws Exception {
+        this.javadocProvider = new JavaDocProvider(javaDocPaths);
+    }
+
+    public void setJavaDocURLs(final URL[] javaDocURLs) {
+        this.javadocProvider = new JavaDocProvider(javaDocURLs);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cxf/blob/ec399a6a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Serializers.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Serializers.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Serializers.java
index 71810d4..0a39b8d 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Serializers.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/swagger/Swagger2Serializers.java
@@ -92,8 +92,8 @@ public class Swagger2Serializers extends SwaggerSerializers {
                 new HashMap<Pair<String, String>, OperationResourceInfo>();
             for (ClassResourceInfo cri : cris) {
                 for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos())
{
-                    String normalizedPath = getNormalizedPath(cri.getURITemplate().getValue(),
ori
-                        .getURITemplate().getValue());
+                    String normalizedPath = getNormalizedPath(
+                            cri.getURITemplate().getValue(), ori.getURITemplate().getValue());
 
                     operations.put(normalizedPath, cri);
                     methods.put(ImmutablePair.of(ori.getHttpMethod(), normalizedPath), ori);
@@ -147,13 +147,9 @@ public class Swagger2Serializers extends SwaggerSerializers {
     }
 
     private String getNormalizedPath(String classResourcePath, String operationResourcePath)
{
-        StringBuilder path = new StringBuilder().
-            append(classResourcePath).
-            append(operationResourcePath);
-
         StringBuilder normalizedPath = new StringBuilder();
 
-        String[] segments = StringUtils.split(path.toString(), "/");
+        String[] segments = StringUtils.split(classResourcePath + operationResourcePath,
"/");
         for (String segment : segments) {
             if (!StringUtils.isEmpty(segment)) {
                 normalizedPath.append("/").append(segment);
@@ -164,6 +160,6 @@ public class Swagger2Serializers extends SwaggerSerializers {
             normalizedPath.setLength(normalizedPath.length() - 4);
             normalizedPath.append('}');
         }
-        return normalizedPath.toString();
+        return StringUtils.EMPTY.equals(normalizedPath.toString()) ? "/" : normalizedPath.toString();
     }
 }


Mime
View raw message