camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: Rest DSL. camel-swagger work in progress.
Date Mon, 11 Aug 2014 10:58:31 GMT
Repository: camel
Updated Branches:
  refs/heads/master 9fec27f64 -> 81b8de2ce


Rest DSL. camel-swagger work in progress.


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

Branch: refs/heads/master
Commit: 81b8de2ce4af9333305f3bfc67d32f3f1577ebdd
Parents: 9fec27f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Aug 11 12:58:21 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Aug 11 12:58:21 2014 +0200

----------------------------------------------------------------------
 .../model/OptionalIdentifiedDefinition.java     | 17 ++++++
 .../apache/camel/model/rest/RestDefinition.java | 47 +++++++++++++-
 .../apache/camel/model/rest/VerbDefinition.java | 11 +++-
 .../rest/FromRestIdAndDescriptionTest.java      | 63 +++++++++++++++++++
 .../SpringFromRestIdAndDescriptionTest.java     | 29 +++++++++
 .../rest/SpringFromRestIdAndDescriptionTest.xml | 64 ++++++++++++++++++++
 .../component/swagger/RestApiListingCache.scala |  3 +
 .../RestSwaggerApiDeclarationServlet.scala      |  3 +
 .../swagger/RestSwaggerCorsFilter.scala         |  4 ++
 .../component/swagger/RestSwaggerReader.scala   | 24 +++++++-
 .../rest/FromRestIdAndDescriptionTest.java      | 49 +++++++++++++++
 .../rest/FromRestIdAndDescriptionTest.xml       | 62 +++++++++++++++++++
 .../camel/example/rest/UserRouteBuilder.java    |  9 +--
 .../src/main/resources/camel-config-xml.xml     |  4 ++
 14 files changed, 380 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
b/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
index f48097b..a40d0fd 100644
--- a/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
@@ -79,6 +79,23 @@ public abstract class OptionalIdentifiedDefinition<T extends OptionalIdentifiedD
     /**
      * Sets the description of this node
      *
+     * @param text  sets the text description, use null to not set a text
+     * @return the builder
+     */
+    @SuppressWarnings("unchecked")
+    public T description(String text) {
+        if (text != null) {
+            if (description == null) {
+                description = new DescriptionDefinition();
+            }
+            description.setText(text);
+        }
+        return (T) this;
+    }
+
+    /**
+     * Sets the description of this node
+     *
      * @param id  sets the id, use null to not set an id
      * @param text  sets the text description, use null to not set a text
      * @param lang  sets the language for the description, use null to not set a language

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index 558b38f..008846c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.model.OptionalIdentifiedDefinition;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.ToDefinition;
 import org.apache.camel.util.URISupport;
@@ -36,7 +37,7 @@ import org.apache.camel.util.URISupport;
  */
 @XmlRootElement(name = "rest")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class RestDefinition {
+public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition> {
 
     @XmlAttribute
     private String path;
@@ -53,6 +54,11 @@ public class RestDefinition {
     @XmlElementRef
     private List<VerbDefinition> verbs = new ArrayList<VerbDefinition>();
 
+    @Override
+    public String getLabel() {
+        return "rest";
+    }
+
     public String getPath() {
         return path;
     }
@@ -152,6 +158,45 @@ public class RestDefinition {
         return addVerb(verb, uri);
     }
 
+    @Override
+    public RestDefinition id(String id) {
+        if (getVerbs().isEmpty()) {
+            super.id(id);
+        } else {
+            // add on last verb as that is how the Java DSL works
+            VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
+            verb.id(id);
+        }
+
+        return this;
+    }
+
+    @Override
+    public RestDefinition description(String text) {
+        if (getVerbs().isEmpty()) {
+            super.description(text);
+        } else {
+            // add on last verb as that is how the Java DSL works
+            VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
+            verb.description(text);
+        }
+
+        return this;
+    }
+
+    @Override
+    public RestDefinition description(String id, String text, String lang) {
+        if (getVerbs().isEmpty()) {
+            super.description(id, text, lang);
+        } else {
+            // add on last verb as that is how the Java DSL works
+            VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
+            verb.description(id, text, lang);
+        }
+
+        return this;
+    }
+
     public RestDefinition consumes(String mediaType) {
         if (getVerbs().isEmpty()) {
             this.consumes = mediaType;

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index fe4dd33..777ed1b 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -30,7 +30,7 @@ import org.apache.camel.model.ToDefinition;
 
 @XmlRootElement(name = "verb")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VerbDefinition {
+public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition> {
 
     @XmlAttribute
     private String method;
@@ -69,6 +69,15 @@ public class VerbDefinition {
     @XmlTransient
     private RestDefinition rest;
 
+    @Override
+    public String getLabel() {
+        if (method != null) {
+            return method;
+        } else {
+            return "verb";
+        }
+    }
+
     public String getMethod() {
         return method;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/camel-core/src/test/java/org/apache/camel/component/rest/FromRestIdAndDescriptionTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestIdAndDescriptionTest.java
b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestIdAndDescriptionTest.java
new file mode 100644
index 0000000..3547e77
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestIdAndDescriptionTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.camel.component.rest;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.rest.RestDefinition;
+
+public class FromRestIdAndDescriptionTest extends FromRestGetTest {
+
+    public void testFromRestModel() throws Exception {
+        super.testFromRestModel();
+
+        RestDefinition rest = context.getRestDefinitions().get(0);
+        assertEquals("hello", rest.getId());
+        assertEquals("Hello Service", rest.getDescriptionText());
+
+        assertEquals("get-say", rest.getVerbs().get(0).getId());
+        assertEquals("Says hello to you", rest.getVerbs().get(0).getDescriptionText());
+
+        RestDefinition rest2 = context.getRestDefinitions().get(1);
+        assertEquals("bye", rest2.getId());
+        assertEquals("Bye Service", rest2.getDescriptionText());
+        assertEquals("en", rest2.getDescription().getLang());
+
+        assertEquals("Says bye to you", rest2.getVerbs().get(0).getDescriptionText());
+        assertEquals("Updates the bye message", rest2.getVerbs().get(1).getDescriptionText());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                rest("/say/hello").id("hello").description("Hello Service")
+                        .get().id("get-say").description("Says hello to you").to("direct:hello");
+
+                rest("/say/bye").description("bye", "Bye Service", "en")
+                        .get().description("Says bye to you").consumes("application/json").to("direct:bye")
+                        .post().description("Updates the bye message").to("mock:update");
+
+                from("direct:hello")
+                        .transform().constant("Hello World");
+
+                from("direct:bye")
+                        .transform().constant("Bye World");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.java
b/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.java
new file mode 100644
index 0000000..b044dc0
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.camel.component.rest;
+
+import org.apache.camel.CamelContext;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringFromRestIdAndDescriptionTest extends FromRestIdAndDescriptionTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.xml");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.xml
new file mode 100644
index 0000000..1b7430a
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestIdAndDescriptionTest.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- use a dummy rest consumer factory for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.component.rest.DummyRestConsumerFactory"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <rest id="hello" path="/say/hello">
+      <description>Hello Service</description>
+      <get id="get-say">
+        <description>Says hello to you</description>
+        <to uri="direct:hello"/>
+      </get>
+    </rest>
+    <rest id="bye" path="/say/bye">
+      <description lang="en">Bye Service</description>
+      <get consumes="application/json">
+        <description>Says bye to you</description>
+        <to uri="direct:bye"/>
+      </get>
+      <post>
+        <description>Updates the bye message</description>
+        <to uri="mock:update"/>
+      </post>
+    </rest>
+
+    <route>
+      <from uri="direct:hello"/>
+      <transform>
+        <constant>Hello World</constant>
+      </transform>
+    </route>
+    <route>
+      <from uri="direct:bye"/>
+      <transform>
+        <constant>Bye World</constant>
+      </transform>
+    </route>
+
+  </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
index 65abddf..2b47bd4 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
@@ -27,6 +27,9 @@ import scala.collection.mutable.ListBuffer
 // to iterate Java list using for loop
 import scala.collection.JavaConverters._
 
+/**
+ * To cache the RestSwaggerReader
+ */
 object RestApiListingCache extends ReaderUtil {
 
   var cache: Option[Map[String, ApiListing]] = None

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerApiDeclarationServlet.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerApiDeclarationServlet.scala
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerApiDeclarationServlet.scala
index c081254..4fa6297 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerApiDeclarationServlet.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerApiDeclarationServlet.scala
@@ -30,6 +30,9 @@ import org.springframework.web.context.WebApplicationContext
 import org.apache.camel.CamelContext
 import org.slf4j.LoggerFactory
 
+/**
+ * A Http Servlet to expose the REST services as Swagger APIs.
+ */
 class RestSwaggerApiDeclarationServlet extends HttpServlet {
 
   // TODO: this has spring dependency, find a way to make it work with blueprint/spring/cdi/servlet-listener
etc

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
index a3bfa26..97460c4 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
@@ -19,6 +19,10 @@ package org.apache.camel.component.swagger
 import javax.servlet._
 import javax.servlet.http.HttpServletResponse
 
+/**
+ * A simple CORS filter that can used to allow the swagger ui or other API browsers from
remote origins to access the
+ * Rest services exposes by this Camel swagger module.
+ */
 class RestSwaggerCorsFilter extends Filter {
 
   override def init(config: FilterConfig): Unit = {

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
index ccd846e..b9ea729 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
@@ -37,10 +37,12 @@ import com.wordnik.swagger.model.ApiListing
 // to iterate Java list using for loop
 import scala.collection.JavaConverters._
 
+/**
+ * A Swagger reader that reads the Camel's Rest models and builds a Swagger ApiListing models.
+ */
 class RestSwaggerReader {
 
   private val LOG = LoggerFactory.getLogger(classOf[RestSwaggerReader])
-  // TODO: add logging
 
   def read(rest: RestDefinition, config: SwaggerConfig): Option[ApiListing] = {
 
@@ -53,6 +55,8 @@ class RestSwaggerReader {
       resourcePath = "/" + resourcePath
     }
 
+    LOG.debug("Reading rest path: {} -> {}", resourcePath, rest)
+
     // create a list of apis
     val apis = new ListBuffer[ApiDescription]
 
@@ -104,11 +108,16 @@ class RestSwaggerReader {
         case _ => List()
       }
 
+      var summary = verb.getDescriptionText
+      if (summary == null) {
+        summary = ""
+      }
 
+      LOG.debug("Adding operation {} {}", method, nickName)
 
       operations += Operation(
         method,
-        "",
+        summary,
         "",
         responseType,
         nickName,
@@ -143,6 +152,14 @@ class RestSwaggerReader {
       }
 
       val models = ModelUtil.modelsFromApis(apis.toList)
+
+      LOG.debug("Adding APIs with {} models", models.size)
+
+      var desc = rest.getDescriptionText
+      if (desc == null) {
+        desc = ""
+      }
+
       Some(
         ApiListing(
           config.apiVersion,
@@ -154,7 +171,8 @@ class RestSwaggerReader {
           List(), // protocols
           List(), // authorizations
           ModelUtil.stripPackages(apis.toList),
-          models)
+          models,
+          Option(desc))
       )
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.java
new file mode 100644
index 0000000..cac2068
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.camel.test.blueprint.component.rest;
+
+import org.apache.camel.model.rest.RestDefinition;
+import org.junit.Test;
+
+public class FromRestIdAndDescriptionTest extends FromRestGetTest {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.xml";
+    }
+
+    @Test
+    public void testFromRestModel() throws Exception {
+        super.testFromRestModel();
+
+        RestDefinition rest = context.getRestDefinitions().get(0);
+        assertEquals("hello", rest.getId());
+        assertEquals("Hello Service", rest.getDescriptionText());
+
+        assertEquals("get-say", rest.getVerbs().get(0).getId());
+        assertEquals("Says hello to you", rest.getVerbs().get(0).getDescriptionText());
+
+        RestDefinition rest2 = context.getRestDefinitions().get(1);
+        assertEquals("bye", rest2.getId());
+        assertEquals("Bye Service", rest2.getDescriptionText());
+        assertEquals("en", rest2.getDescription().getLang());
+
+        assertEquals("Says bye to you", rest2.getVerbs().get(0).getDescriptionText());
+        assertEquals("Updates the bye message", rest2.getVerbs().get(1).getDescriptionText());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.xml
new file mode 100644
index 0000000..2801271
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestIdAndDescriptionTest.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <!-- use a dummy rest consumer factory for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.test.blueprint.component.rest.DummyRestConsumerFactory"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+    <rest id="hello" path="/say/hello">
+      <description>Hello Service</description>
+      <get id="get-say">
+        <description>Says hello to you</description>
+        <to uri="direct:hello"/>
+      </get>
+    </rest>
+    <rest id="bye" path="/say/bye">
+      <description lang="en">Bye Service</description>
+      <get consumes="application/json">
+        <description>Says bye to you</description>
+        <to uri="direct:bye"/>
+      </get>
+      <post>
+        <description>Updates the bye message</description>
+        <to uri="mock:update"/>
+      </post>
+    </rest>
+
+    <route>
+      <from uri="direct:hello"/>
+      <transform>
+        <constant>Hello World</constant>
+      </transform>
+    </route>
+    <route>
+      <from uri="direct:bye"/>
+      <transform>
+        <constant>Bye World</constant>
+      </transform>
+    </route>
+
+  </camelContext>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/examples/camel-example-servlet-rest-tomcat/src/main/java/org/apache/camel/example/rest/UserRouteBuilder.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-rest-tomcat/src/main/java/org/apache/camel/example/rest/UserRouteBuilder.java
b/examples/camel-example-servlet-rest-tomcat/src/main/java/org/apache/camel/example/rest/UserRouteBuilder.java
index 1aabafc..0bcdf36 100644
--- a/examples/camel-example-servlet-rest-tomcat/src/main/java/org/apache/camel/example/rest/UserRouteBuilder.java
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/java/org/apache/camel/example/rest/UserRouteBuilder.java
@@ -47,15 +47,16 @@ public class UserRouteBuilder extends RouteBuilder {
             .contextPath("camel-example-servlet-rest-tomcat/rest").port(8080);
 
         // this user REST service is json only
-        rest("/user").consumes("application/json").produces("application/json")
+        rest("/user").description("User rest service")
+            .consumes("application/json").produces("application/json")
 
-            .get("/{id}").outType(User.class)
+            .get("/{id}").description("Find user by id").outType(User.class)
                 .to("bean:userService?method=getUser(${header.id})")
 
-            .put().type(User.class)
+            .put().description("Updates or create a user").type(User.class)
                 .to("bean:userService?method=updateUser")
 
-            .get("/findAll").outTypeList(User.class)
+            .get("/findAll").description("Find all users").outTypeList(User.class)
                 .to("bean:userService?method=listUsers");
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/81b8de2c/examples/camel-example-servlet-rest-tomcat/src/main/resources/camel-config-xml.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-rest-tomcat/src/main/resources/camel-config-xml.xml
b/examples/camel-example-servlet-rest-tomcat/src/main/resources/camel-config-xml.xml
index 82192e6..5dc4bd3 100755
--- a/examples/camel-example-servlet-rest-tomcat/src/main/resources/camel-config-xml.xml
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/resources/camel-config-xml.xml
@@ -41,19 +41,23 @@
 
     <!-- defines the rest services using the context-path /user -->
     <rest path="/user" consumes="application/json" produces="application/json">
+      <description>User rest service</description>
 
       <!-- this is a rest GET to view an user by the given id -->
       <get uri="/{id}" outType="org.apache.camel.example.rest.User">
+        <description>Find user by id</description>
         <to uri="bean:userService?method=getUser(${header.id})"/>
       </get>
 
       <!-- this is a rest PUT to create/update an user -->
       <put type="org.apache.camel.example.rest.User">
+        <description>Updates or create a user</description>
         <to uri="bean:userService?method=updateUser"/>
       </put>
 
       <!-- this is a rest GET to find all users -->
       <get uri="/findAll" outType="org.apache.camel.example.rest.User[]">
+        <description>Find all users</description>
         <to uri="bean:userService?method=listUsers"/>
       </get>
 


Mime
View raw message