Added redirect for the /onos/v1/docs Swagger UI URL.  Added onos-rsdocs tool to launch REST API docs UI from shell.

Change-Id: Ifb839e0205e5b176ebc7bb48644925eaa3675fd9
diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile
index d084c97..fd609b9 100644
--- a/tools/dev/bash_profile
+++ b/tools/dev/bash_profile
@@ -30,6 +30,11 @@
 # Setup cell enviroment
 export ONOS_CELL=${ONOS_CELL:-local}
 
+# Setup default web user; for local dev execution use Karaf defaults
+export ONOS_WEB_USER=${ONOS_WEB_USER:-karaf}
+export ONOS_WEB_PASS=${ONOS_WEB_PASS:-karaf}
+
+# Setup default location of test scenarios
 export ONOS_SCENARIOS=$ONOS_ROOT/tools/test/scenarios
 
 # Convenience utility to warp to various ONOS source projects
@@ -78,8 +83,9 @@
 # Pretty-print JSON output
 alias pp='python -m json.tool'
 
-# Short-hand to launch API docs and sample topology viewer GUI
+# Short-hand to launch Java API docs, REST API docs and ONOS GUI
 alias docs='open $ONOS_ROOT/docs/target/site/apidocs/index.html'
+alias rsdocs='onos-rsdocs'
 alias gui='onos-gui'
 
 
diff --git a/tools/test/bin/onos-rsdocs b/tools/test/bin/onos-rsdocs
new file mode 100755
index 0000000..bc0127c
--- /dev/null
+++ b/tools/test/bin/onos-rsdocs
@@ -0,0 +1,9 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Launches ONOS REST API docs GUI on the specified node.
+# -----------------------------------------------------------------------------
+
+host=${1:-$OCI}
+host=${host:-localhost}
+
+open http://$host:8181/onos/v1/docs
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ApiDocResource.java b/web/api/src/main/java/org/onosproject/rest/resources/ApiDocResource.java
index fa124f5..0ad4fc6 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ApiDocResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ApiDocResource.java
@@ -23,15 +23,20 @@
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.SequenceInputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import static com.google.common.collect.ImmutableList.of;
 import static com.google.common.io.ByteStreams.toByteArray;
 import static javax.ws.rs.core.MediaType.*;
+import static javax.ws.rs.core.Response.temporaryRedirect;
 import static org.onlab.util.Tools.nullIsNotFound;
 
 /**
@@ -48,6 +53,9 @@
     private static final String INJECT_START = "<!-- {API-START} -->";
     private static final String INJECT_END = "<!-- {API-END} -->";
 
+    @Context
+    private UriInfo uriInfo;
+
     /**
      * Get all registered REST API docs.
      * Returns array of all registered API docs.
@@ -102,8 +110,9 @@
      */
     @GET
     @Path("/")
-    public Response getDefault() throws IOException {
-        return getIndex();
+    public Response getDefault() throws IOException, URISyntaxException {
+        return uriInfo.getPath().endsWith("/") ? getIndex() :
+                temporaryRedirect(new URI(uriInfo.getPath() + "/")).build();
     }
 
     /**