Bug 3708 - APIdoc explorer URLs contain extra 'node' in REST calls 31/37631/1
authorRyan Goulding <ryandgoulding@gmail.com>
Thu, 14 Apr 2016 15:30:33 +0000 (11:30 -0400)
committerRyan Goulding <ryandgoulding@gmail.com>
Thu, 14 Apr 2016 20:09:21 +0000 (16:09 -0400)
* fixed mount point path builder that added each list qname twice

Manually cherry picked from controller patch to netconf patch:
https://git.opendaylight.org/gerrit/#/c/25531

Change-Id: I631961f3b0d791c6e8ab2921ef6eb163e68e7753
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java
restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java

index 1726e2aad0a32a3e637cfe09ec715ac576e272b5..b20aa967b9e66f38a37cb1ee59e353a51190c15d 100644 (file)
@@ -90,25 +90,19 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
             builder.append(moduleName);
             builder.append(':');
         }
-        boolean first = true;
         for (PathArgument arg : key.getPathArguments()) {
-
             String name = arg.getNodeType().getLocalName();
-            if (first) {
-                first = false;
-            } else {
-                builder.append('/');
-            }
-            builder.append(name);
             if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
                 NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg;
                 for (Entry<QName, Object> entry : nodeId.getKeyValues().entrySet()) {
-                    builder.append('/').append(entry.getValue());
+                    builder.append(entry.getValue()).append('/');
                 }
+            } else {
+                builder.append(name);
+                builder.append('/');
             }
         }
-
-        return builder.append('/').toString();
+        return builder.toString();
     }
 
     private String getYangMountUrl(final YangInstanceIdentifier key) {
index 7b3344348ae96f38ba2ecca2df7d87157974d44a..881f9e95657e0ae3df0fc9a0a80a813b62c7334c 100644 (file)
@@ -42,6 +42,7 @@ public class MountPointSwaggerTest {
     private static final String HTTP_URL = "http://localhost/path";
     private static final YangInstanceIdentifier instanceId = YangInstanceIdentifier.builder()
             .node(QName.create("nodes"))
+            .node(QName.create("node"))
             .nodeWithKey(QName.create("node"), QName.create("id"), "123").build();
     private static final String INSTANCE_URL = "nodes/node/123/";
     private MountPointSwagger swagger;