activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1306554 [1/3] - in /activemq/activemq-apollo/trunk/apollo-web: ./ src/main/scala/org/apache/activemq/apollo/web/ src/main/scala/org/apache/activemq/apollo/web/resources/ src/main/webapp/api/ src/main/webapp/api/javascripts/ src/main/webapp...
Date Wed, 28 Mar 2012 19:40:13 GMT
Author: chirino
Date: Wed Mar 28 19:40:12 2012
New Revision: 1306554

URL: http://svn.apache.org/viewvc?rev=1306554&view=rev
Log:
Integrated swagger based API doco.  Resource paths changed a bit too.

Added:
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ApolloApiListing.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/SessionResource.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/index.html
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/javascripts/
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/javascripts/app.js
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/javascripts/swagger-service.js
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/javascripts/swagger-ui.js
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/stylesheets/
    activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/stylesheets/screen.css
Modified:
    activemq/activemq-apollo/trunk/apollo-web/pom.xml
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/StaticContentFilter.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/WebModule.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala

Modified: activemq/activemq-apollo/trunk/apollo-web/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/pom.xml?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-web/pom.xml Wed Mar 28 19:40:12 2012
@@ -59,12 +59,6 @@
       <version>${jersey-version}</version>
     </dependency>
     <dependency>
-      <groupId>javax.servlet</groupId>
-      <artifactId>servlet-api</artifactId>
-      <version>${servlet-api-version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-jaxrs</artifactId>
       <version>${jackson-version}</version>
@@ -76,6 +70,18 @@
     </dependency>
 
     <dependency>
+      <groupId>com.wordnik</groupId>
+      <artifactId>swagger-jaxrs_2.9.1</artifactId>
+      <version>1.02-SNAPSHOT</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>servlet-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
       <groupId>org.eclipse.jetty.aggregate</groupId>
       <artifactId>jetty-all-server</artifactId>
       <version>${jetty-version}</version>
@@ -108,6 +114,20 @@
       <artifactId>scalate-test</artifactId>
       <version>${scalate-version}</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-server</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-webapp</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-util</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.activemq</groupId>

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala Wed Mar 28 19:40:12 2012
@@ -21,7 +21,6 @@ import javax.servlet.ServletConfig
 import javax.servlet.ServletContext
 import java.util.Enumeration
 import collection.mutable.HashMap
-// import com.wordnik.swagger.jaxrs.JaxrsApiReader
 
 /**
  * <p>
@@ -55,12 +54,12 @@ class JerseyServlet extends ServletConta
   }
 
   override def init(config: ServletConfig): Unit = {
-    // JaxrsApiReader.setFormatString("")
+    com.wordnik.swagger.jaxrs.JaxrsApiReader.setFormatString("")
 
     original_config = config
     custom_config_map.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.ClassNamesResourceConfig")
     custom_config_map.put("com.sun.jersey.config.property.classnames", WebModule.web_resources.map(_.getName).mkString(" "))
-    // custom_config_map.put("com.sun.jersey.config.feature.Trace", System.getProperty("com.sun.jersey.config.feature.Trace", "true"))
+    custom_config_map.put("com.sun.jersey.config.feature.Trace", System.getProperty("com.sun.jersey.config.feature.Trace", "true"))
     custom_config_map.put("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.PostReplaceFilter")
     custom_config_map.put("com.sun.jersey.config.feature.Redirect", "true")
     custom_config_map.put("com.sun.jersey.config.feature.FilterForwardOn404", "true")

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/StaticContentFilter.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/StaticContentFilter.scala?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/StaticContentFilter.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/StaticContentFilter.scala Wed Mar 28 19:40:12 2012
@@ -1,3 +1,19 @@
+/**
+ * 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.activemq.apollo.web
 
 import javax.servlet._

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/WebModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/WebModule.scala?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/WebModule.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/WebModule.scala Wed Mar 28 19:40:12 2012
@@ -21,7 +21,7 @@ import collection.immutable.TreeMap
 import collection.mutable.LinkedHashMap
 import resources._
 import org.fusesource.scalate.jersey._
-//import com.wordnik.swagger.jaxrs.ApiHelpMessageBodyWriter
+import com.wordnik.swagger.jaxrs.ApiHelpMessageBodyWriter
 
 trait WebModule {
   def priority:Int
@@ -58,22 +58,20 @@ object DefaultWebModule extends WebModul
   override def web_resources = Set(
     classOf[RootResource],
 
-//    classOf[ApolloApiListing],
-//    classOf[ApiHelpMessageBodyWriter],
+    classOf[ApolloApiListing],
+    classOf[ApiHelpMessageBodyWriter],
 
-    classOf[BrokerResource],
-//    classOf[BrokerResourceHTML],
-//    classOf[BrokerResourceJSON],
-//    classOf[BrokerResourceHelp],
-
-//    classOf[SessionResourceHTML],
-//    classOf[SessionResourceJSON],
-//    classOf[SessionResourceHelp],
-
-    classOf[ConfigurationResource],
-//    classOf[ConfigurationResourceHTML],
-//    classOf[ConfigurationResourceJSON],
-//    classOf[ConfigurationResourceHelp],
+    classOf[BrokerResourceHTML],
+    classOf[BrokerResourceJSON],
+    classOf[BrokerResourceHelp],
+
+    classOf[SessionResourceHTML],
+    classOf[SessionResourceJSON],
+    classOf[SessionResourceHelp],
+
+    classOf[ConfigurationResourceHTML],
+    classOf[ConfigurationResourceJSON],
+    classOf[ConfigurationResourceHelp],
 
     classOf[JacksonJsonProvider],
     classOf[JaxrsExceptionMapper],

Added: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ApolloApiListing.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ApolloApiListing.scala?rev=1306554&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ApolloApiListing.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ApolloApiListing.scala Wed Mar 28 19:40:12 2012
@@ -0,0 +1,66 @@
+/**
+ * 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.activemq.apollo.web.resources
+
+import javax.ws.rs._
+import core.{HttpHeaders, UriInfo, Context}
+import org.apache.activemq.apollo.broker._
+import javax.servlet.ServletConfig
+import com.wordnik.swagger.jaxrs.{Help, ApiListing}
+import com.sun.jersey.spi.resource.Singleton
+import com.sun.jersey.api.core.ResourceConfig
+import com.wordnik.swagger.core.{Documentation, ApiOperation, Api}
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+@Path(       "/api{ext:(\\.json)?}")
+@Produces(Array("application/json"))
+class ApolloApiListing extends ApiListing {
+  @GET
+  @ApiOperation(value = "Returns list of all available api endpoints", responseClass = "DocumentationEndPoint", multiValueResponse = true)
+  override def getAllApis(
+    @Context sc: ServletConfig,
+    @Context rc: ResourceConfig,
+    @Context headers: HttpHeaders,
+    @Context uriInfo: UriInfo) = {
+    val response = super.getAllApis(sc, rc, headers, uriInfo)
+    val doc = response.getEntity.asInstanceOf[Documentation]
+    doc.apiVersion = Broker.version
+    doc.basePath = uriInfo.getAbsolutePath.resolve(".").toString.stripSuffix("/")
+    response
+  }
+}
+
+/**
+ * Jersey seems to have trouble getting annotations from traits.. so lets
+ * make a concrete class out of the Help trait..
+ */
+@Singleton
+@Produces(Array("application/json"))
+class HelpResourceJSON extends Help {
+  @GET
+  @ApiOperation(value = "Returns information about API parameters",
+    responseClass = "com.wordnik.swagger.core.Documentation")
+  override def getHelp(@Context sc: ServletConfig,
+    @Context rc: ResourceConfig,
+    @Context headers: HttpHeaders,
+    @Context uriInfo: UriInfo) = super.getHelp(sc, rc, headers, uriInfo)
+}
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala Wed Mar 28 19:40:12 2012
@@ -22,21 +22,36 @@ import scala.collection.Iterable
 import org.apache.activemq.apollo.util.path.PathParser
 import org.apache.activemq.apollo.util._
 import javax.ws.rs._
-import core.Response.Status
-import core.{Response, Context}
+import core.Context
 import javax.ws.rs.core.Response.Status._
 import management.ManagementFactory
 import javax.management.ObjectName
 import javax.management.openmbean.CompositeData
 import org.josql.{QueryResults, Query}
 import java.util.regex.Pattern
-import javax.servlet.http.HttpServletResponse
 import java.util.{Collections, ArrayList}
 import org.apache.activemq.apollo.broker._
-import java.security.Principal
 import org.apache.activemq.apollo.dto._
 import javax.ws.rs.core.MediaType._
-import security.SecurityContext
+import com.wordnik.swagger.core._
+import javax.servlet.http.HttpServletResponse
+
+@Path(          "/api/json/broker")
+@Api(value =    "/api/json/broker",
+  listingPath = "/api/docs/broker")
+@Produces(Array("application/json"))
+class BrokerResourceJSON extends BrokerResource
+
+@Path(          "/api/docs/broker{ext:(\\.json)?}")
+@Api(value =    "/api/json/broker",
+  listingPath = "/api/docs/broker",
+  listingClass = "org.apache.activemq.apollo.web.resources.BrokerResourceJSON")
+class BrokerResourceHelp extends HelpResourceJSON
+
+@Path("/broker")
+@Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML, "text/html;qs=5"))
+class BrokerResourceHTML extends BrokerResource
+
 
 /**
  * <p>
@@ -46,96 +61,49 @@ import security.SecurityContext
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@Path("/broker")
-@Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML, "text/html;qs=5"))
 class BrokerResource() extends Resource {
   import Resource._
 
-  @GET
-  @Path("whoami")
-  def whoami():java.util.List[PrincipalDTO] = {
-    val rc: Set[Principal] = with_broker { broker =>
-      val rc = FutureResult[Set[Principal]]()
-      if(broker.authenticator!=null) {
-        authenticate(broker.authenticator) { security_context =>
-          if(security_context!=null) {
-            rc.set(Success(security_context.principals))
-          } else {
-            rc.set(Success(Set[Principal]()))
-          }
-        }
-      } else {
-        rc.set(Success(Set[Principal]()))
-      }
-      rc
-    }
-    import collection.JavaConversions._
-    new ArrayList[PrincipalDTO](rc.map(x=>new PrincipalDTO(x.getClass.getName, x.getName)))
+  def SessionResource() = {
+    val rc = new SessionResource()
+    rc.setHttpRequest(http_request)
+    rc
   }
 
-  @Produces(Array("text/html;qs=5"))
+  @Deprecated("The session resource should be used instead.")
   @GET
-  @Path("signin")
-  def get_signin_html(@Context response:HttpServletResponse, @QueryParam("username") username:String, @QueryParam("password") password:String): ErrorDTO = {
-    if(post_signin(response, username, password)) {
-      result(strip_resolve("../.."))
-    } else {
-      var dto = new ErrorDTO()
-      dto.code = "%d: %s".format(BAD_REQUEST.getStatusCode, BAD_REQUEST.getReasonPhrase)
-      dto.message = "Invalid user id or password";
-      result(BAD_REQUEST, dto)
-    }
-  }
+  @Path("/whoami")
+  def whoami() = SessionResource().whoami()
 
-//  @GET
-//  @Path("signin")
-//  def get_signin(@Context response:HttpServletResponse, @QueryParam("username") username:String, @QueryParam("password") password:String):Boolean = {
-//    post_signin(response, username, password)
-//  }
+  @Deprecated("The session resource should be used instead.")
+  @Produces(Array("text/html;qs=5"))
+  @GET
+  @Path("/signin")
+  def get_signin_html(@Context response:HttpServletResponse,
+                      @QueryParam("username") username:String,
+                      @QueryParam("password") password:String,
+                      @QueryParam("target") target:String
+                             ): ErrorDTO = SessionResource().get_signin_html(response, username, password, target)
 
+  @Deprecated("The session resource should be used instead.")
   @POST
-  @Path("signin")
-  def post_signin(@Context response:HttpServletResponse, @FormParam("username") username:String, @FormParam("password") password:String):Boolean =  {
-    try {
-      val user_info = UserInfo(username, password)
-      http_request.setAttribute("user_info", user_info)
-      unwrap_future_result[Boolean] {
-        with_broker { broker =>
-          monitoring(broker) {
-            // Only create the session if he is a valid user.
-            val session = http_request.getSession(true)
-            user_info.security_context = http_request.getAttribute(SECURITY_CONTEXT_ATTRIBUTE).asInstanceOf[SecurityContext]
-            session.setAttribute("user_info", user_info)
-            true
-          }
-        }
-      }
-    } catch {
-      case e:WebApplicationException => // this happens if user is not authorized
-        e.printStackTrace()
-        false
-    }
-  }
+  @Path("/signin")
+  def post_signin(@Context response:HttpServletResponse,
+                  @FormParam("username") username:String,
+                  @FormParam("password") password:String):Boolean = SessionResource().post_signin(response, username, password, target)
 
+  @Deprecated("The session resource should be used instead.")
   @Produces(Array("text/html"))
-  @GET @Path("signout")
-  def signout_html():String = {
-    signout()
-    result(strip_resolve("../.."))
-    ""
-  }
+  @GET @Path("/signout")
+  def signout_html():String = SessionResource().signout_html()
 
+  @Deprecated("The session resource should be used instead.")
   @Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML))
-  @GET @Path("signout")
-  def signout():String =  {
-    val session = http_request.getSession(false)
-    if( session !=null ) {
-      session.invalidate();
-    }
-    ""
-  }
+  @GET @Path("/signout")
+  def signout():String = SessionResource().signout()
 
   @GET
+  @ApiOperation(value = "Returns a BrokerStatusDTO which contains summary information about the broker and the JVM")
   def get_broker():BrokerStatusDTO = {
     with_broker { broker =>
       monitoring(broker) {
@@ -229,6 +197,7 @@ class BrokerResource() extends Resource 
 
   @GET
   @Path("/queue-metrics")
+  @ApiOperation(value = "Returns an AggregateDestMetricsDTO holding the summary of all the queue metrics")
   def get_queue_metrics(): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_broker { broker =>
       monitoring(broker) {
@@ -241,6 +210,7 @@ class BrokerResource() extends Resource 
 
   @GET
   @Path("/topic-metrics")
+  @ApiOperation(value = "Returns an AggregateDestMetricsDTO holding the summary of all the topic metrics")
   def get_topic_metrics(): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_broker { broker =>
       monitoring(broker) {
@@ -253,6 +223,7 @@ class BrokerResource() extends Resource 
 
   @GET
   @Path("/dsub-metrics")
+  @ApiOperation(value = "Returns an AggregateDestMetricsDTO holding the summary of all the durable subscription metrics")
   def get_dsub_metrics(): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_broker { broker =>
       monitoring(broker) {
@@ -278,6 +249,7 @@ class BrokerResource() extends Resource 
 
   @GET
   @Path("/dest-metrics")
+  @ApiOperation(value = "Returns an AggregateDestMetricsDTO holding the summary of all the destination metrics")
   def get_dest_metrics(): AggregateDestMetricsDTO = {
     aggregate(get_queue_metrics(), get_topic_metrics(), get_dsub_metrics())
   }
@@ -324,6 +296,7 @@ class BrokerResource() extends Resource 
 
   @GET @Path("/virtual-hosts")
   @Produces(Array(APPLICATION_JSON))
+  @ApiOperation(value = "Returns an DataPageDTO holding all the virtual hosts")
   def virtual_host(@QueryParam("f") f:java.util.List[String], @QueryParam("q") q:String,
                   @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
 
@@ -338,6 +311,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}")
+  @ApiOperation(value = "Returns a VirtualHostStatusDTO holding the status of the requested virtual host")
   def virtual_host(@PathParam("id") id : String):VirtualHostStatusDTO = {
     with_virtual_host(id) { host =>
       monitoring(host) {
@@ -370,6 +344,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/queue-metrics")
+  @ApiOperation(value = "Aggregates the messaging metrics for all the queue destinations")
   def virtual_host_queue_metrics(@PathParam("id") id : String): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_virtual_host(id) { host =>
       monitoring(host) {
@@ -381,6 +356,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/topic-metrics")
+  @ApiOperation(value = "Aggregates the messaging metrics for all the topic destinations")
   def virtual_host_topic_metrics(@PathParam("id") id : String): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_virtual_host(id) { host =>
       monitoring(host) {
@@ -392,6 +368,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/dsub-metrics")
+  @ApiOperation(value = "Aggregates the messaging metrics for all the durable subscription destinations")
   def virtual_host_dsub_metrics(@PathParam("id") id : String): AggregateDestMetricsDTO = {
     val rc:AggregateDestMetricsDTO = with_virtual_host(id) { host =>
       monitoring(host) {
@@ -403,12 +380,14 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/dest-metrics")
+  @ApiOperation(value = "Aggregates the messaging metrics for all the destinations")
   def virtual_host_dest_metrics(@PathParam("id") id : String): AggregateDestMetricsDTO = {
     aggregate(virtual_host_queue_metrics(id), virtual_host_topic_metrics(id), virtual_host_dsub_metrics(id))
   }
 
 
   @GET @Path("/virtual-hosts/{id}/store")
+  @ApiOperation(value = "Gets metrics about the status of the message store used by the {host} virtual host.")
   def store(@PathParam("id") id : String):StoreStatusDTO = {
     with_virtual_host(id) { host =>
       monitoring(host) {
@@ -501,7 +480,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/topics")
-//  @ApiOperation(value = "Gets a list of all the topics that exist on the broker.")
+  @ApiOperation(value = "Gets a list of all the topics that exist on the broker.")
   @Produces(Array(APPLICATION_JSON))
   def topics(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String],
             @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
@@ -520,6 +499,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/topics/{name:.*}")
+  @ApiOperation(value = "Gets the status of the named topic.")
   def topic(@PathParam("id") id : String, @PathParam("name") name : String):TopicStatusDTO = {
     with_virtual_host(id) { host =>
       val router:LocalRouter = host
@@ -531,6 +511,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/topic-queues/{name:.*}/{qid}")
+  @ApiOperation(value = "Gets the status of a topic consumer queue.")
   def topic(@PathParam("id") id : String,@PathParam("name") name : String,  @PathParam("qid") qid : Long, @QueryParam("entries") entries:Boolean):QueueStatusDTO = {
     with_virtual_host(id) { host =>
       val router:LocalRouter = host
@@ -545,6 +526,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/queues")
+  @ApiOperation(value = "Gets a list of all the queues that exist on the broker.")
   @Produces(Array(APPLICATION_JSON))
   def queues(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String],
             @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
@@ -562,6 +544,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/queues/{name:.*}")
+  @ApiOperation(value = "Gets the status of the named queue.")
   def queue(@PathParam("id") id : String, @PathParam("name") name : String, @QueryParam("entries") entries:Boolean ):QueueStatusDTO = {
     with_virtual_host(id) { host =>
       val router: LocalRouter = host
@@ -574,6 +557,7 @@ class BrokerResource() extends Resource 
 
   @DELETE @Path("/virtual-hosts/{id}/queues/{name:.*}")
   @Produces(Array(APPLICATION_JSON, APPLICATION_XML,TEXT_XML))
+  @ApiOperation(value = "Deletes the named queue.")
   def queue_delete(@PathParam("id") id : String, @PathParam("name") name : String):Unit = unwrap_future_result {
     with_virtual_host(id) { host =>
       val router: LocalRouter = host
@@ -592,6 +576,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/dsubs")
+  @ApiOperation(value = "Gets a list of all the durable subscriptions that exist on the broker.")
   @Produces(Array(APPLICATION_JSON))
   def durable_subscriptions(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String],
             @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
@@ -609,6 +594,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/virtual-hosts/{id}/dsubs/{name:.*}")
+  @ApiOperation(value = "Gets the status of the named durable subscription.")
   def durable_subscription(@PathParam("id") id : String, @PathParam("name") name : String, @QueryParam("entries") entries:Boolean):QueueStatusDTO = {
     with_virtual_host(id) { host =>
       val router:LocalRouter = host
@@ -621,6 +607,7 @@ class BrokerResource() extends Resource 
 
 
   @DELETE @Path("/virtual-hosts/{id}/dsubs/{name:.*}")
+  @ApiOperation(value = "Deletes the named virtual host.")
   @Produces(Array(APPLICATION_JSON, APPLICATION_XML,TEXT_XML))
   def dsub_delete(@PathParam("id") id : String, @PathParam("name") name : String):Unit = unwrap_future_result {
     with_virtual_host(id) { host =>
@@ -653,6 +640,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/connectors")
+  @ApiOperation(value = "Gets a paginated view of all the the connectors .")
   @Produces(Array(APPLICATION_JSON))
   def connectors(@QueryParam("f") f:java.util.List[String], @QueryParam("q") q:String,
                   @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
@@ -668,6 +656,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/connectors/{id}")
+  @ApiOperation(value = "Gets the status of the specified connector.")
   def connector(@PathParam("id") id : String):ServiceStatusDTO = {
     with_connector(id) { connector =>
       monitoring(connector.broker) {
@@ -677,6 +666,7 @@ class BrokerResource() extends Resource 
   }
 
   @POST @Path("/connectors/{id}/action/stop")
+  @ApiOperation(value = "Stops a connector.")
   def post_connector_stop(@PathParam("id") id : String):Unit = unwrap_future_result {
     with_connector(id) { connector =>
       admining(connector.broker) {
@@ -687,6 +677,7 @@ class BrokerResource() extends Resource 
   }
 
   @POST @Path("/connectors/{id}/action/start")
+  @ApiOperation(value = "Starts a connector.")
   def post_connector_start(@PathParam("id") id : String):Unit = unwrap_future_result {
     with_connector(id) { connector =>
       admining(connector.broker) {
@@ -698,6 +689,7 @@ class BrokerResource() extends Resource 
 
   @GET
   @Path("/connection-metrics")
+  @ApiOperation(value = "Aggregates connection metreics for all the connectors.")
   def get_connection_metrics(): AggregateConnectionMetricsDTO = {
     val f = new ArrayList[String]()
     f.add("read_counter")
@@ -724,6 +716,7 @@ class BrokerResource() extends Resource 
 
 
   @GET @Path("/connections")
+  @ApiOperation(value = "A paged view of all the connections.")
   @Produces(Array(APPLICATION_JSON))
   def connections(@QueryParam("f") f:java.util.List[String], @QueryParam("q") q:String,
                   @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer, @QueryParam("o") o:java.util.List[String] ):DataPageDTO = {
@@ -742,6 +735,7 @@ class BrokerResource() extends Resource 
   }
 
   @GET @Path("/connections/{id}")
+  @ApiOperation(value = "Gets that status of a connection.")
   def connection(@PathParam("id") id : Long):ConnectionStatusDTO = {
     with_connection(id){ connection=>
       monitoring(connection.connector.broker) {
@@ -751,6 +745,7 @@ class BrokerResource() extends Resource 
   }
 
   @DELETE @Path("/connections/{id}")
+  @ApiOperation(value = "Disconnect a connection from the broker.")
   @Produces(Array(APPLICATION_JSON, APPLICATION_XML,TEXT_XML))
   def connection_delete(@PathParam("id") id : Long):Unit = unwrap_future_result {
     with_connection(id){ connection=>
@@ -762,6 +757,7 @@ class BrokerResource() extends Resource 
 
 
   @POST @Path("/connections/{id}/action/delete")
+  @ApiOperation(value = "Disconnect a connection from the broker.")
   @Produces(Array("text/html;qs=5"))
   def post_connection_delete_and_redirect(@PathParam("id") id : Long):Unit = unwrap_future_result {
     connection_delete(id)
@@ -770,6 +766,7 @@ class BrokerResource() extends Resource 
 
   @POST
   @Path("/action/shutdown")
+  @ApiOperation(value = "Shutsdown the JVM")
   def command_shutdown:Unit = unwrap_future_result {
     info("JVM shutdown requested via web interface")
     with_broker { broker =>

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala?rev=1306554&r1=1306553&r2=1306554&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala Wed Mar 28 19:40:12 2012
@@ -23,15 +23,30 @@ import org.apache.activemq.apollo.util.F
 import javax.ws.rs._
 import javax.ws.rs.core.Response.Status._
 import javax.ws.rs.core.MediaType._
+import com.wordnik.swagger.core.{ApiOperation, Api}
 
 case class EditConfig(file:String, config:String, can_write:Boolean)
 case class ListConfigs(files:Array[String])
 
+@Path(          "/api/json/broker/config")
+@Api(value =    "/api/json/broker/config",
+  listingPath = "/api/docs/broker/config")
+@Produces(Array("application/json"))
+class ConfigurationResourceJSON extends ConfigurationResource
+
+@Path(          "/api/docs/broker/config{ext:(\\.json)?}")
+@Api(value =    "/api/json/broker/config",
+  listingPath = "/api/docs/broker/config",
+  listingClass = "org.apache.activemq.apollo.web.resources.ConfigurationResourceJSON")
+class ConfigurationResourceHelp extends HelpResourceJSON
+
+@Path("/broker/config")
+@Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML, "text/html;qs=5"))
+class ConfigurationResourceHTML extends ConfigurationResource
+
 /**
  * A broker resource is used to represent the configuration of a broker.
  */
-@Path("/broker/config")
-@Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML, "text/html;qs=5"))
 class ConfigurationResource extends Resource {
 
   lazy val etc_directory = {
@@ -52,7 +67,8 @@ class ConfigurationResource extends Reso
 
   @GET
   @Path("runtime")
-  @Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML))
+//  @Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML))
+//  @ApiOperation(value = "Returns a BrokerDTO object with runtime configuraiton of the broker.")
   def runtime = {
 
     // Encode/Decode the runtime config so that we can get a copy that
@@ -72,6 +88,7 @@ class ConfigurationResource extends Reso
 
   @GET
   @Path("/files")
+  @ApiOperation(value = "Returns the list of configuration files.")
   @Produces(Array(APPLICATION_JSON))
   def list() = {
     etc_directory.listFiles().flatMap { file =>
@@ -86,6 +103,7 @@ class ConfigurationResource extends Reso
   @GET
   @Produces(Array(TEXT_HTML))
   @Path("/files")
+  @ApiOperation(value = "Returns the list of configuration files.")
   def list_html() = {
     ListConfigs(list())
   }
@@ -93,6 +111,7 @@ class ConfigurationResource extends Reso
   @GET
   @Produces(Array(APPLICATION_OCTET_STREAM))
   @Path("/files/{name}")
+  @ApiOperation(value = "Returns the contents of the configuration file.")
   def get(@PathParam("name") name:String) = {
     val file = etc_directory / name
     if( !file.exists() || !file.canRead || file.getParentFile != etc_directory ) {
@@ -115,6 +134,7 @@ class ConfigurationResource extends Reso
   @POST
   @Consumes(Array(WILDCARD))
   @Path("/files/{name}")
+  @ApiOperation(value = "Updates the contents of the configuration file.")
   def put(@PathParam("name") name:String, config:Array[Byte]):Unit = {
     val file = etc_directory / name
     if( !file.exists() || !file.canWrite || file.getParentFile != etc_directory ) {

Added: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/SessionResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/SessionResource.scala?rev=1306554&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/SessionResource.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/SessionResource.scala Wed Mar 28 19:40:12 2012
@@ -0,0 +1,155 @@
+/**
+ * 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.activemq.apollo.web.resources;
+
+import java.{lang => jl}
+import org.apache.activemq.apollo.util._
+import javax.ws.rs._
+import core.Context
+import javax.ws.rs.core.Response.Status._
+import javax.servlet.http.HttpServletResponse
+import java.util.ArrayList
+import java.security.Principal
+import org.apache.activemq.apollo.dto._
+import javax.ws.rs.core.MediaType._
+import org.apache.activemq.apollo.broker.security.SecurityContext
+import com.wordnik.swagger.core._
+
+@Path(          "/api/json/session")
+@Api(value =    "/api/json/session",
+  listingPath = "/api/docs/session")
+@Produces(Array("application/json"))
+class SessionResourceJSON extends SessionResource
+
+@Path(          "/api/docs/session{ext:(\\.json)?}")
+@Api(value =    "/api/json/session",
+  listingPath = "/api/docs/session",
+  listingClass = "org.apache.activemq.apollo.web.resources.SessionResourceJSON")
+class SessionResourceHelp extends HelpResourceJSON
+
+@Path("/session")
+@Produces(Array("text/html"))
+class SessionResourceHTML extends SessionResource
+
+/**
+ * <p>
+ * Used to manage user web sessions.
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class SessionResource extends Resource {
+  import Resource._
+
+  @GET
+  @Path("/whoami")
+  @ApiOperation(value = "Returns the Signed-in user's pricipals")
+  def whoami():java.util.List[PrincipalDTO] = {
+    val rc: Set[Principal] = with_broker { broker =>
+      val rc = FutureResult[Set[Principal]]()
+      if(broker.authenticator!=null) {
+        authenticate(broker.authenticator) { security_context =>
+          if(security_context!=null) {
+            rc.set(Success(security_context.principals))
+          } else {
+            rc.set(Success(Set[Principal]()))
+          }
+        }
+      } else {
+        rc.set(Success(Set[Principal]()))
+      }
+      rc
+    }
+    import collection.JavaConversions._
+    new ArrayList[PrincipalDTO](rc.map(x=>new PrincipalDTO(x.getClass.getName, x.getName)))
+  }
+
+  @Produces(Array("text/html;qs=5"))
+  @GET
+  @Path("/signin")
+  @ApiOperation(value = "Signin a user")
+  @ApiErrors(Array(
+    new ApiError(code = 400, reason = "Invalid user id or password")
+  ))
+  def get_signin_html(@Context response:HttpServletResponse,
+                      @ApiParam(value = "User Name", defaultValue="admin")
+                      @QueryParam("username") username:String,
+                      @ApiParam(value = "User Password", defaultValue="password")
+                      @QueryParam("password") password:String,
+                      @ApiParam(value = "On success, redirect to the specified URL", defaultValue = "/")
+                      @QueryParam("target") target:String
+                             ): ErrorDTO = {
+    if(post_signin(response, username, password)) {
+      result(strip_resolve(Option(target).getOrElse("/")))
+    } else {
+      var dto = new ErrorDTO()
+      dto.code = "%d: %s".format(BAD_REQUEST.getStatusCode, BAD_REQUEST.getReasonPhrase)
+      dto.message = "Invalid user id or password";
+      result(BAD_REQUEST, dto)
+    }
+  }
+
+  @POST
+  @Path("/signin")
+  @ApiOperation(value = "Signin a user")
+  def post_signin(@Context response:HttpServletResponse,
+                  @ApiParam(value = "User Name")
+                  @FormParam("username") username:String,
+                  @ApiParam(value = "User Password")
+                  @FormParam("password") password:String):Boolean =  {
+    try {
+      val user_info = UserInfo(username, password)
+      http_request.setAttribute("user_info", user_info)
+      unwrap_future_result[Boolean] {
+        with_broker { broker =>
+          monitoring(broker) {
+            // Only create the session if he is a valid user.
+            val session = http_request.getSession(true)
+            user_info.security_context = http_request.getAttribute(SECURITY_CONTEXT_ATTRIBUTE).asInstanceOf[SecurityContext]
+            session.setAttribute("user_info", user_info)
+            true
+          }
+        }
+      }
+    } catch {
+      case e:WebApplicationException => // this happens if user is not authorized
+        e.printStackTrace()
+        false
+    }
+  }
+
+  @Produces(Array("text/html"))
+  @GET @Path("/signout")
+  @ApiOperation(value = "Signout a user")
+  def signout_html():String = {
+    signout()
+    result(strip_resolve("../.."))
+    ""
+  }
+
+  @Produces(Array(APPLICATION_JSON, APPLICATION_XML, TEXT_XML))
+  @GET @Path("/signout")
+  @ApiOperation(value = "Signout a user")
+  def signout():String =  {
+    val session = http_request.getSession(false)
+    if( session !=null ) {
+      session.invalidate();
+    }
+    ""
+  }
+
+}

Added: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/index.html
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/index.html?rev=1306554&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/index.html (added)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/api/index.html Wed Mar 28 19:40:12 2012
@@ -0,0 +1,169 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+  <head>
+    <meta charset='utf-8' />
+    <!-- Always force latest IE rendering engine (even in intranet) and Chrome Frame -->
+    <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' />
+    <title>Swagger API Explorer</title>
+    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css' />
+    <link href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css' media='screen' rel='stylesheet' type='text/css' />
+    <link href='stylesheets/screen.css' media='screen' rel='stylesheet' type='text/css' />
+    <script src='javascripts/app.js' type='text/javascript'></script>
+    <script src='javascripts/swagger-service.js' type='text/javascript'></script>
+    <script src='javascripts/swagger-ui.js' type='text/javascript'></script>
+  </head>
+  <body>
+    <div id='header' >
+      <a id="logo" href="http://activemq.apache.org/apollo">Apollo REST API Explorer</a>
+      <form id='api_selector' style="display:none">
+        <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text" value="/api.json" /></div>
+        <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text" /></div>
+        <div class='input'><a id="explore" href="#">Explore</a></div>
+      </form>
+    </div>
+    <div class='container' id='resources_container'>
+      <ul id='resources'></ul>
+    </div>
+    <script type="text/x-jquery-tmpl" id="resourceTemplate"><li class='resource' id='resource_${name}'>
+      <div class='heading'>
+        <h2>
+          <a href='#!/${name}' onclick="Docs.toggleEndpointListForResource('${name}');">${path}</a>
+        </h2>
+        <ul class='options'>
+          <li>
+            <a href='#!/${name}' id='endpointListTogger_${name}' onclick="Docs.toggleEndpointListForResource('${name}');">Show/Hide</a>
+          </li>
+          <li>
+            <a href='#' onclick="Docs.collapseOperationsForResource('${name}'); return false;">
+              List Operations
+            </a>
+          </li>
+          <li>
+            <a href='#' onclick="Docs.expandOperationsForResource('${name}'); return false;">
+              Expand Operations
+            </a>
+          </li>
+          <li>
+            <a href='${baseUrl}${path_json}'>Raw</a>
+          </li>
+        </ul>
+      </div>
+      <ul class='endpoints' id='${name}_endpoint_list' style='display:none'></ul>
+    </li>
+    </script>
+    <script type="text/x-jquery-tmpl" id="apiTemplate"><li class='endpoint'>
+      <ul class='operations' id='${name}_endpoint_operations'></ul>
+    </li>
+    </script>
+    <script type="text/x-jquery-tmpl" id="operationTemplate"><li class='${httpMethodLowercase} operation' id='${apiName}_${nickname}_${httpMethod}'>
+      <div class='heading'>
+        <h3>
+          <span class='http_method'>
+            <a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${httpMethod}</a>
+          </span>
+          <span class='path'>
+            <a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${path_json}</a>
+          </span>
+        </h3>
+        <ul class='options'>
+          <li>
+            <a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${summary}</a>
+          </li>
+        </ul>
+      </div>
+      <div class='content' id='${apiName}_${nickname}_${httpMethod}_content' style='display:none'>
+        {{if notes}}
+        <h4>Implementation Notes</h4>
+        <p>${notes}</p>
+        {{/if}}
+        <form accept-charset='UTF-8' action='#' class='sandbox' id='${apiName}_${nickname}_${httpMethod}_form' method='post'>
+          <div style='margin:0;padding:0;display:inline'></div>
+          <h4>Parameters</h4>
+          <table class='fullwidth'>
+            <thead>
+              <tr>
+                <th>Parameter</th>
+                <th id='${apiName}_${nickname}_${httpMethod}_value_header'>Value</th>
+                <th>Description</th>
+              </tr>
+            </thead>
+            <tbody id='${apiName}_${nickname}_${httpMethod}_params'></tbody>
+          </table>
+          <div class='sandbox_header' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_header'>
+            <input class='submit' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_button' name='commit' type='button' value='Try it out!' />
+            <a href='#' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_hider' onclick="$('#${apiName}_${nickname}_${httpMethod}_content_sandbox_response').slideUp();$(this).fadeOut(); return false;" style='display:none'>Hide Response</a>
+            <img alt='Throbber' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_throbber' src='http://swagger.wordnik.com/images/throbber.gif' style='display:none' />
+          </div>
+        </form>
+        <div class='response' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response' style='display:none'>
+          <h4>Request URL</h4>
+          <div class='block request_url'></div>
+          <h4>Response Body</h4>
+          <div class='block response_body'></div>
+          <h4>Response Code</h4>
+          <div class='block response_code'></div>
+          <h4>Response Headers</h4>
+          <div class='block response_headers'></div>
+        </div>
+      </div>
+    </li>
+    </script>
+    <script type="text/x-jquery-tmpl" id="paramTemplate"><tr>
+      <td class='code'>${name}</td>
+      <td>
+        <input minlength='0' name='${name}' placeholder='' type='text' value='' />
+      </td>
+      <td width='500'>${description}</td>
+    </tr>
+    </script>
+    <script type="text/x-jquery-tmpl" id="paramTemplateSelect"><tr>
+      <td class='code'>${name}</td>
+      <td>
+        <select name='${name}'>
+          {{if required == false }}
+          <option selected='selected' value=''></option>
+          {{/if}}
+          {{each allowableValues.values}}
+          {{if $value == defaultValue && required == true }}
+          <option selected='selected' value='${$value}'>${$value}</option>
+          {{else}}
+          <option value='${$value}'>${$value}</option>
+          {{/if}}
+          {{/each}}
+        </select>
+      </td>
+      <td width='500'>${description}</td>
+    </tr>
+    </script>
+    <script type="text/x-jquery-tmpl" id="paramTemplateRequired"><tr>
+      <td class='code required'>${name}</td>
+      <td>
+        <input class='required' minlength='1' name='${name}' placeholder='(required)' type='text' value='' />
+      </td>
+      <td width='500'>
+        <strong>${description}</strong>
+      </td>
+    </tr>
+    </script>
+    <script type="text/x-jquery-tmpl" id="paramTemplateRequiredReadOnly"><tr>
+      <td class='code required'>${name}</td>
+      <td>-</td>
+      <td width='500'>${description}</td>
+    </tr>
+    </script>
+    <script type="text/x-jquery-tmpl" id="paramTemplateReadOnly"><tr>
+      <td class='code'>${name}</td>
+      <td>-</td>
+      <td width='500'>${description}</td>
+    </tr>
+    </script>
+    <div id='content_message'>
+      Enter the base URL of the API that you wish to explore, or try
+      <a onclick="$('#input_baseUrl').val('http://petstore.swagger.wordnik.com/api/resources.json'); apiSelectionController.showApi(); return false;" href="#">petstore.swagger.wordnik.com/api/resources.json</a>
+    </div>
+    <p id='colophon' style='display:none'>
+      Sexy API documentation from
+      <a href="http://swagger.wordnik.com">Swagger</a>.
+    </p>
+  </body>
+</html>



Mime
View raw message