git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 965d2377a -> 14cd8d6b3


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/14cd8d6b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/14cd8d6b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/14cd8d6b

Branch: refs/heads/master
Commit: 14cd8d6b32d8f6b3eb4fe2fe62947c11c3a5c935
Parents: 965d237
Author: Claus Ibsen 
Authored: Sun Aug 10 16:55:10 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 16:55:10 2014 +0200

--
 .../camel/component/netty/http/ContextPathMatcher.java |  5 +++--
 .../netty/http/DefaultContextPathMatcher.java  |  8 
 .../component/netty/http/RestContextPathMatcher.java   |  6 +++---
 .../netty/http/handlers/HttpServerChannelHandler.java  |  2 --
 .../handlers/HttpServerMultiplexChannelHandler.java|  6 +-
 .../camel/component/swagger/RestSwaggerReader.scala|  5 +
 .../src/main/webapp/WEB-INF/web.xml| 13 -
 7 files changed, 24 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/14cd8d6b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ContextPathMatcher.java
--
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ContextPathMatcher.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ContextPathMatcher.java
index 030fb9f..a3c02d8 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ContextPathMatcher.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ContextPathMatcher.java
@@ -29,8 +29,9 @@ public interface ContextPathMatcher {
 /**
  * Whether the target context-path matches.
  *
- * @param target  the context-path from the incoming HTTP request
+ * @param method the HTTP method such as GET, POST
+ * @param path  the context-path from the incoming HTTP request
  * @return true to match, false if not.
  */
-boolean matches(String target);
+boolean matches(String method, String path);
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/14cd8d6b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultContextPathMatcher.java
--
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultContextPathMatcher.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultContextPathMatcher.java
index 2efc357..e1a4d52 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultContextPathMatcher.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultContextPathMatcher.java
@@ -31,14 +31,14 @@ public class DefaultContextPathMatcher implements 
ContextPathMatcher {
 this.matchOnUriPrefix = matchOnUriPrefix;
 }
 
-public boolean matches(String target) {
-target = target.toLowerCase(Locale.US);
+public boolean matches(String method, String path) {
+path = path.toLowerCase(Locale.US);
 if (!matchOnUriPrefix) {
 // exact match
-return target.equals(path);
+return path.equals(this.path);
 } else {
 // match on prefix, then we just need to match the start of the 
context-path
-return target.startsWith(path);
+return path.startsWith(this.path);
 }
 }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/14cd8d6b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
--
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
index f7e73db..f0838e3 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
@@ -31,11 +31,11 @@ public class RestContextPathMatcher extends 
DefaultContextPathMatcher {
 }
 
 @Override
-public boolean matches(String target) {
+public boolean matches(String method, String path) {
 if (useRestMatching(rawPath)) {
-return matchRestPath(target, rawPath);
+return matchRestPath

git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 7113dee32 -> 965d2377a


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/965d2377
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/965d2377
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/965d2377

Branch: refs/heads/master
Commit: 965d2377ab5c3ddca3bc39bcc42330d18cc05dfa
Parents: 7113dee
Author: Claus Ibsen 
Authored: Sun Aug 10 16:38:50 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 16:38:50 2014 +0200

--
 .../camel/component/http/CamelServlet.java  | 16 ++-
 ...JettyRestServletResolveConsumerStrategy.java |  7 ++-
 .../netty/http/RestContextPathMatcher.java  |  2 ++
 .../http/handlers/HttpServerChannelHandler.java | 21 
 ...rvletRestServletResolveConsumerStrategy.java |  7 ++-
 .../camel/example/rest/UserRouteBuilder.java|  2 +-
 .../apache/camel/example/rest/UserService.java  |  5 ++---
 .../src/main/resources/camel-config-xml.xml |  2 +-
 8 files changed, 54 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/965d2377/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
--
diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
index 926d25d..f70b57b 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
@@ -74,9 +74,23 @@ public class CamelServlet extends HttpServlet {
 response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
 return;
 }
+
+// if its an OPTIONS request then return which method is allowed
+if ("OPTIONS".equals(request.getMethod())) {
+String s;
+if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
+s = "OPTIONS," + 
consumer.getEndpoint().getHttpMethodRestrict();
+} else {
+// allow them all
+s = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,PATCH";
+}
+response.addHeader("Allow", s);
+response.setStatus(HttpServletResponse.SC_OK);
+return;
+}
 
 if (consumer.getEndpoint().getHttpMethodRestrict() != null 
-&& 
!consumer.getEndpoint().getHttpMethodRestrict().equals(request.getMethod())) {
+&& 
!consumer.getEndpoint().getHttpMethodRestrict().contains(request.getMethod())) {
 response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
 return;
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/965d2377/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
--
diff --git 
a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
 
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
index 1a7e05a..a8c3a4f 100644
--- 
a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
+++ 
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
@@ -152,7 +152,12 @@ public class JettyRestServletResolveConsumerStrategy 
extends HttpServletResolveC
 return true;
 }
 
-return 
method.toLowerCase(Locale.US).endsWith(restrict.toLowerCase(Locale.US));
+// always match OPTIONS as some REST clients uses that prior to 
calling the service
+if ("OPTIONS".equals(method)) {
+return true;
+}
+
+return 
restrict.toLowerCase(Locale.US).contains(method.toLowerCase(Locale.US));
 }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/965d2377/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
--
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
index c48e815..f7e73db 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/RestContextPathMatcher.java
+++ 
b/components/camel-netty

[2/2] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/7113dee3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7113dee3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7113dee3

Branch: refs/heads/master
Commit: 7113dee32c80e1f39298446e9c9bd1d988fe9494
Parents: 0472b3e
Author: Claus Ibsen 
Authored: Sun Aug 10 15:48:00 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 15:48:00 2014 +0200

--
 .../swagger/RestSwaggerCorsFilter.scala | 43 
 .../src/main/webapp/WEB-INF/web.xml | 16 +---
 2 files changed, 54 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/7113dee3/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
new file mode 100644
index 000..a3bfa26
--- /dev/null
+++ 
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerCorsFilter.scala
@@ -0,0 +1,43 @@
+/**
+ * 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.swagger
+
+import javax.servlet._
+import javax.servlet.http.HttpServletResponse
+
+class RestSwaggerCorsFilter extends Filter {
+
+  override def init(config: FilterConfig): Unit = {
+// noop
+  }
+
+  override def destroy(): Unit = {
+// noop
+  }
+
+  override def doFilter(request: ServletRequest, response: ServletResponse, 
chain: FilterChain): Unit = {
+val res = response.asInstanceOf[HttpServletResponse]
+
+res.setHeader("Access-Control-Allow-Origin", "*")
+res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, 
DELETE, TRACE, OPTIONS, CONNECT, PATCH")
+res.setHeader("Access-Control-Max-Age", "3600")
+res.setHeader("Access-Control-Allow-Headers", "Origin, Accept, 
X-Requested-With, Content-Type, Access-Control-Request-Method, 
Access-Control-Request-Headers")
+
+chain.doFilter(request, response)
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7113dee3/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
--
diff --git 
a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml 
b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
index 6b43d03..ee0c9f1 100755
--- a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
@@ -54,11 +54,6 @@
 
org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet
 2
 
-  
-  cors
-  true
-
-
   base.path
   http://localhost:8080/rest
 
@@ -93,4 +88,15 @@
 /rest/*
   
 
+  
+  
+RestSwaggerCorsFilter
+
org.apache.camel.component.swagger.RestSwaggerCorsFilter
+  
+
+  
+RestSwaggerCorsFilter
+/*
+  
+
 
\ No newline at end of file



[1/2] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 753bf7410 -> 7113dee32


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/0472b3e2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0472b3e2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0472b3e2

Branch: refs/heads/master
Commit: 0472b3e264e3f9a6519b48bf151bd1b3f76ede35
Parents: 753bf74
Author: Claus Ibsen 
Authored: Sun Aug 10 15:26:45 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 15:26:45 2014 +0200

--
 .../component/swagger/RestSwaggerReader.scala   | 81 
 1 file changed, 67 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/0472b3e2/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 7522595..aa48d61 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
@@ -19,7 +19,7 @@ package org.apache.camel.component.swagger
 import java.util.Locale
 
 import com.wordnik.swagger.config.SwaggerConfig
-import com.wordnik.swagger.model.{ApiDescription, Operation, ApiListing}
+import com.wordnik.swagger.model._
 import com.wordnik.swagger.core.util.ModelUtil
 import com.wordnik.swagger.core.SwaggerSpec
 
@@ -28,6 +28,11 @@ import org.apache.camel.util.FileUtil
 import org.slf4j.LoggerFactory
 
 import scala.collection.mutable.ListBuffer
+import com.wordnik.swagger.model.Parameter
+import com.wordnik.swagger.model.ApiDescription
+import scala.Some
+import com.wordnik.swagger.model.Operation
+import com.wordnik.swagger.model.ApiListing
 
 // to iterate Java list using for loop
 import scala.collection.JavaConverters._
@@ -36,18 +41,6 @@ class RestSwaggerReader {
 
   private val LOG = LoggerFactory.getLogger(classOf[RestSwaggerReader])
 
-  def buildUrl(path1: String, path2: String): String = {
-val s1 = FileUtil.stripTrailingSeparator(path1)
-val s2 = FileUtil.stripLeadingSeparator(path2)
-if (s1 != null && s2 != null) {
-  s1 + "/" + s2
-} else if (path1 != null) {
-  path1
-} else {
-  path2
-}
-  }
-
   // TODO: add parameters to operations
   // - {id} is a path type, and required
   // - type/outType is body type and required
@@ -114,6 +107,8 @@ class RestSwaggerReader {
 case _ => List()
   }
 
+
+
   operations += Operation(
 method,
 "",
@@ -125,7 +120,7 @@ class RestSwaggerReader {
 consumes,
 List(),
 List(),
-List(),
+createParameters(verb, buildUrl(resourcePath, path)),
 List(),
 None)
 }
@@ -169,6 +164,52 @@ class RestSwaggerReader {
 else None
   }
 
+  def createParameters(verb: VerbDefinition, absPath : String): 
List[Parameter] = {
+val parameters = new ListBuffer[Parameter]
+
+// each {} is a parameter
+val arr = absPath.split("\\/")
+for (a <- arr) {
+  if (a.startsWith("{") && a.endsWith("}")) {
+var key = a.substring(1, a.length - 1)
+
+parameters += Parameter(
+  key,
+  None,
+  None,
+  true,
+  false,
+  "string",
+  AnyAllowableValues,
+  "path",
+  None
+)
+  }
+}
+
+// if we have input type then its a body parameter
+if (verb.getType != null) {
+  var bodyType = verb.getType
+  if (bodyType.endsWith("[]")) {
+bodyType = "List[" + bodyType.substring(0, bodyType.length - 2) + "]"
+  }
+
+  parameters += Parameter(
+"body",
+None,
+None,
+true,
+false,
+bodyType,
+AnyAllowableValues,
+"body",
+None
+  )
+}
+
+parameters.toList
+  }
+
   def createNickname(method: String, absPath : String): String = {
 val s = method + "/" + absPath
 val arr = s.split("\\/")
@@ -192,4 +233,16 @@ class RestSwaggerReader {
 s.replaceAll("\\W", "")
   }
 
+  def buildUrl(path1: String, path2: String): String = {
+val s1 = FileUtil.stripTrailingSeparator(path1)
+val s2 = FileUtil.stripLeadingSeparator(path2)
+if (s1 != null && s2 != null) {
+  s1 + "/" + s2
+} else if (path1 != null) {
+  path1
+} else {
+  path2
+}
+  }
+
 }



svn commit: r918936 - in /websites/production/camel/content: cache/main.pageCache swagger.html

2014-08-10 Thread buildbot
Author: buildbot
Date: Sun Aug 10 11:17:51 2014
New Revision: 918936

Log:
Production update by buildbot for camel

Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/swagger.html

Modified: websites/production/camel/content/cache/main.pageCache
==
Binary files - no diff available.

Modified: websites/production/camel/content/swagger.html
==
--- websites/production/camel/content/swagger.html (original)
+++ websites/production/camel/content/swagger.html Sun Aug 10 11:17:51 2014
@@ -94,7 +94,7 @@
 
 
 ]]>
-UsingTo use this you need to 
configure 
the org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet in
 the WEB-INF/web.xml file as shown below:Error formatting macro: snippet: 
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20 OptionsThe org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet supports
 the following options which can be configured as context-param in the web.xml 
file.OptionTypeDescriptionswagger.version
 StringSwagger spec version. Is default 
1.2.base.path StringRequired: To setup the base path where 
the API is availableapi.versionStringThe version of the api. Is default 0.0.0.api.pathStringPath of the apiapi.titleStringRequired. The title of the 
application.api.descriptionStringRequired. A short description 
of the application.api.termsOfServiceUrlStringA URL to the Terms of Service of the 
API.api.contactStringAn email to be used for API-related 
correspondence.api.licenseStringThe license name used for the 
API.api.licenseUrlStringA URL to the license used for the 
API.ExamplesTODO: rest example
+UsingTo use this you need to 
configure 
the org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet in
 the WEB-INF/web.xml file as shown below:Error formatting macro: snippet: 
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20 OptionsThe org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet supports
 the following options which can be configured as context-param in the web.xml 
file.OptionTypeDescriptioncorsBooleanWhether to enable CORS. Is default 
false.swagger.versionStringSwagger spec version. Is default 1.2.base.path StringRequired: To setup the base 
path where the REST services is availableapi.versionStringThe version of the api. Is default 0.0.0.api.pathStringTo setup the path where the API is available (eg 
/api-docs)api.titleStringRequired. The title of the 
application.api.descriptionStringRequired. A short description 
of the application.api.termsOfServiceUrlStringA URL to the Terms of Service of the 
API.api.contactStringAn email to be used for API-related 
correspondence.api.licenseStringThe license name used for the 
API.api.licenseUrlStringA URL to the license used for the 
API.ExamplesTODO: rest example
 
 
   




[CONF] Apache Camel > Swagger

2014-08-10 Thread Claus Ibsen (Confluence)














  


Claus Ibsen edited the page:
 


Swagger   






...



 div








class
confluenceTableSmall


 









 Option 
 Type 
 Description 


cors
Boolean
Whether to enable CORS. Is default false.


swagger.version
String
Swagger spec version. Is default 1.2.


base.path  
String
Required: To setup the base path where the API REST services is available


api.version
String

git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 2fb649050 -> 753bf7410


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/753bf741
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/753bf741
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/753bf741

Branch: refs/heads/master
Commit: 753bf741065d5311b399aeb4b06717d9fecd7bc9
Parents: 2fb6490
Author: Claus Ibsen 
Authored: Sun Aug 10 13:07:07 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 13:07:07 2014 +0200

--
 .../swagger/RestSwaggerApiDeclarationServlet.scala | 17 +
 .../src/main/webapp/WEB-INF/web.xml| 11 ++-
 2 files changed, 27 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/753bf741/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 fb72242..c081254 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
@@ -40,6 +40,7 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
   val reader = new RestSwaggerReader()
   var camel: CamelContext = null
   val swaggerConfig: SwaggerConfig = ConfigFactory.config
+  var cors: Boolean = false
 
   override def init(config: ServletConfig): Unit = {
 super.init(config)
@@ -61,6 +62,10 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
 if (s != null) {
   swaggerConfig.setApiPath(s)
 }
+s = config.getInitParameter("cors")
+if (s != null) {
+  cors = "true".equalsIgnoreCase(s)
+}
 
 val title = config.getInitParameter("api.title")
 val description = config.getInitParameter("api.description")
@@ -104,6 +109,12 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet 
{
 val cookies = Map[String, String]()
 val headers = Map[String, List[String]]()
 
+if (cors) {
+  response.addHeader("Access-Control-Allow-Headers", "Origin, Accept, 
X-Requested-With, Content-Type, Access-Control-Request-Method, 
Access-Control-Request-Headers")
+  response.addHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, 
PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH")
+  response.addHeader("Access-Control-Allow-Origin", "*")
+}
+
 if (camel != null) {
   val f = new SpecFilter
   val listings = RestApiListingCache.listing(camel, 
swaggerConfig).map(specs => {
@@ -142,6 +153,12 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet 
{
 val headers = Map[String, List[String]]()
 val pathPart = docRoot
 
+if (cors) {
+  response.addHeader("Access-Control-Allow-Headers", "Origin, Accept, 
X-Requested-With, Content-Type, Access-Control-Request-Method, 
Access-Control-Request-Headers")
+  response.addHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, 
PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH")
+  response.addHeader("Access-Control-Allow-Origin", "*")
+}
+
 if (camel != null) {
   val listings = RestApiListingCache.listing(camel, 
swaggerConfig).map(specs => {
   (for (spec <- specs.values) yield {

http://git-wip-us.apache.org/repos/asf/camel/blob/753bf741/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
--
diff --git 
a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml 
b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
index 7fd5d5f..6b43d03 100755
--- a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
@@ -44,7 +44,7 @@
 CamelServlet
 Camel Http Transport Servlet
 
org.apache.camel.component.servlet.CamelHttpTransportServlet
-3
+1
   
 
   
@@ -54,7 +54,16 @@
 
org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet
 2
 
+  
+  cors
+  true
+
+
   base.path
+  http://localhost:8080/rest
+
+
+  api.path
   http://localhost:8080/api-docs
 
 



git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 50e8ed779 -> 2fb649050


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/2fb64905
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2fb64905
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2fb64905

Branch: refs/heads/master
Commit: 2fb649050408e88558e9f9f2dc889418ab5e4fdb
Parents: 50e8ed7
Author: Claus Ibsen 
Authored: Sun Aug 10 12:21:44 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 12:21:44 2014 +0200

--
 .../camel/model/rest/RestBindingDefinition.java | 38 ++--
 .../apache/camel/model/rest/RestDefinition.java | 16 +++--
 .../apache/camel/model/rest/VerbDefinition.java | 22 
 .../component/swagger/RestSwaggerReader.scala   |  3 +-
 .../src/main/resources/camel-config-xml.xml |  2 +-
 5 files changed, 17 insertions(+), 64 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/2fb64905/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
 
b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
index 7099c90..5655ca5 100644
--- 
a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
+++ 
b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
@@ -29,7 +29,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.model.NoOutputDefinition;
 import org.apache.camel.processor.binding.RestBindingProcessor;
 import org.apache.camel.spi.DataFormat;
-import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.IntrospectionSupport;
 
@@ -52,12 +51,6 @@ public class RestBindingDefinition extends 
NoOutputDefinition {
 @XmlAttribute
 private String outType;
 
-@XmlAttribute
-private Boolean list;
-
-@XmlAttribute
-private Boolean outList;
-
 @Override
 public String toString() {
 return "RestBinding";
@@ -100,22 +93,24 @@ public class RestBindingDefinition extends 
NoOutputDefinition {
 if (json != null) {
 Class clazz = null;
 if (type != null) {
-clazz = context.getClassResolver().resolveMandatoryClass(type);
+String typeName = type.endsWith("[]") ? type.substring(0, 
type.length() - 2) : type;
+clazz = 
context.getClassResolver().resolveMandatoryClass(typeName);
 }
 if (clazz != null) {
 IntrospectionSupport.setProperty(context.getTypeConverter(), 
json, "unmarshalType", clazz);
-IntrospectionSupport.setProperty(context.getTypeConverter(), 
json, "useList", list != null ? list : false);
+IntrospectionSupport.setProperty(context.getTypeConverter(), 
json, "useList", type.endsWith("[]"));
 }
 setAdditionalConfiguration(context, json);
 context.addService(json);
 
 Class outClazz = null;
 if (outType != null) {
-outClazz = 
context.getClassResolver().resolveMandatoryClass(outType);
+String typeName = outType.endsWith("[]") ? 
outType.substring(0, outType.length() - 2) : outType;
+outClazz = 
context.getClassResolver().resolveMandatoryClass(typeName);
 }
 if (outClazz != null) {
 IntrospectionSupport.setProperty(context.getTypeConverter(), 
outJson, "unmarshalType", outClazz);
-IntrospectionSupport.setProperty(context.getTypeConverter(), 
outJson, "useList", outList != null ? outList : false);
+IntrospectionSupport.setProperty(context.getTypeConverter(), 
outJson, "useList", outType.endsWith("[]"));
 }
 setAdditionalConfiguration(context, outJson);
 context.addService(outJson);
@@ -136,7 +131,8 @@ public class RestBindingDefinition extends 
NoOutputDefinition {
 if (jaxb != null) {
 Class clazz = null;
 if (type != null) {
-clazz = context.getClassResolver().resolveMandatoryClass(type);
+String typeName = type.endsWith("[]") ? type.substring(0, 
type.length() - 2) : type;
+clazz = 
context.getClassResolver().resolveMandatoryClass(typeName);
 }
 if (clazz != null) {
 JAXBContext jc = JAXBContext.newInstance(clazz);
@@ -150,7 +146,8 @@ public class RestBindingDefinition extends 
NoOutputDefinition {
 
 Class outClazz = null;
 if (outType != null) {
-outCla

svn commit: r918932 - in /websites/production/camel/content: cache/main.pageCache rest-dsl.html swagger.html

2014-08-10 Thread buildbot
Author: buildbot
Date: Sun Aug 10 10:17:52 2014
New Revision: 918932

Log:
Production update by buildbot for camel

Added:
websites/production/camel/content/swagger.html
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/rest-dsl.html

Modified: websites/production/camel/content/cache/main.pageCache
==
Binary files - no diff available.

Modified: websites/production/camel/content/rest-dsl.html
==
--- websites/production/camel/content/rest-dsl.html (original)
+++ websites/production/camel/content/rest-dsl.html Sun Aug 10 10:17:52 2014
@@ -249,7 +249,7 @@ public class UserPojo {
 
 And with XML 
DSL
 
-You can configure properties on these 
levels. component - Is used to set any options on the 
Component class. You can also configure these directly on the 
component.endpoint - Is used set any option on the endpoint level. 
Many of the Camel components has many options you can set on endpoint 
level.consumer - Is used to set any option on the consumer level. Some 
components has consumer options, which you can also configure from endpoint 
level by prefixing the option with "consumer." data format - Is 
used to set any option on the data formats. For example to enable pretty print 
in the json data format.You can set multiple options of the same 
level, so you can can for example configure 2 component options, and 3 endpoint 
options etc.Integration a Camel 
component with Rest DSLAny
  Apache Camel component can integrate with the Rest DSL if they can be used as 
a REST service (eg as a REST consumer in Camel lingo). To integrate with the 
Rest DSL, then the component should implement 
the org.apache.camel.spi.RestConsumerFactory. The Rest DSL 
will then invoke the createConsumer method when it setup the 
Camel routes from the defined DSL. The component should then implement logic to 
create a Camel consumer that exposes the REST services based on the given 
parameters, such as path, verb, and other options. For example see the source 
code for camel-restlet, camel-spark-rest. See AlsoDSLRestSpark-restHow do I import rests 
from other XML files
+You can configure properties on these 
levels. component - Is used to set any options on the 
Component class. You can also configure these directly on the 
component.endpoint - Is used set any option on the endpoint level. 
Many of the Camel components has many options you can set on endpoint 
level.consumer - Is used to set any option on the consumer level. Some 
components has consumer options, which you can also configure from endpoint 
level by prefixing the option with "consumer." data format - Is 
used to set any option on the data formats. For example to enable pretty print 
in the json data format.You can set multiple options of the same 
level, so you can can for example configure 2 component options, and 3 endpoint 
options etc.Integration a Camel 
component with Rest DSLAny
  Apache Camel component can integrate with the Rest DSL if they can be used as 
a REST service (eg as a REST consumer in Camel lingo). To integrate with the 
Rest DSL, then the component should implement 
the org.apache.camel.spi.RestConsumerFactory. The Rest DSL 
will then invoke the createConsumer method when it setup the 
Camel routes from the defined DSL. The component should then implement logic to 
create a Camel consumer that exposes the REST services based on the given 
parameters, such as path, verb, and other options. For example see the source 
code for camel-restlet, camel-spark-rest.Swagger APIThe Rest DSL supports Swagger by 
the camel-swagger module. See more details at  Swagger and 
the camel-example-servlet-rest-tomcat example from the Apache 
Camel distribution.See Alsohref="dsl.html">DSLhref="rest.html">Resthref="swagger.html">Swaggerhref="spark-rest.html">Spark-resthref="how-do-i-import-rests-from-other-xml-files.html">How do I import rests 
 >from other XML files
 
 
   

Added: websites/production/camel/content/swagger.html
==
--- websites/production/camel/content/swagger.html (added)
+++ websites/production/camel/content/swagger.html Sun Aug 10 10:17:52 2014
@@ -0,0 +1,166 @@
+http://www.w3.org/TR/html4/loose.dtd";>
+
+
+
+
+
+
+
+
+
+
+
+
+  .maincontent { overflow:hidden; }
+
+
+
+
+  
+  
+  
+  
+  
+  
+  
+  
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+  
+

[08/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/3f821b09
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3f821b09
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3f821b09

Branch: refs/heads/master
Commit: 3f821b0975470a9aebe03029dd9d4d765b209e5d
Parents: 8b3d645
Author: Claus Ibsen 
Authored: Sun Aug 10 10:36:30 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 10:39:59 2014 +0200

--
 .../component/swagger/RestApiListingCache.scala | 11 ++---
 .../RestSwaggerApiDeclarationServlet.scala  | 11 +++--
 .../component/swagger/RestSwaggerReader.scala   | 47 +---
 3 files changed, 53 insertions(+), 16 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/3f821b09/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 494e620..65abddf 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
@@ -18,8 +18,10 @@ package org.apache.camel.component.swagger
 
 import com.wordnik.swagger.core.util.ReaderUtil
 import com.wordnik.swagger.config.SwaggerConfig
+import com.wordnik.swagger.model.ApiListing
+
 import org.apache.camel.CamelContext
-import com.wordnik.swagger.model.{Operation, ApiListing}
+
 import scala.collection.mutable.ListBuffer
 
 // to iterate Java list using for loop
@@ -36,10 +38,9 @@ object RestApiListingCache extends ReaderUtil {
 
   val rests = camel.getRestDefinitions.asScala
   for (rest <- rests) {
-// TODO: this can be nicer
-val option = reader.read(rest, config)
-if (option.get != null) {
-  listings += option.get
+val some = reader.read(rest, config)
+if (!some.isEmpty) {
+  listings += some.get
 }
   }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3f821b09/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 11af449..fb72242 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
@@ -43,7 +43,6 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
 
   override def init(config: ServletConfig): Unit = {
 super.init(config)
-LOG.info("init")
 
 // configure swagger options
 var s = config.getInitParameter("api.version")
@@ -99,13 +98,12 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
* Renders the resource listing which is the overview of all the apis
*/
   def renderResourceListing(request: HttpServletRequest, response: 
HttpServletResponse) = {
-LOG.info("renderResourceListing")
+LOG.trace("renderResourceListing")
 
 val queryParams = Map[String, List[String]]()
 val cookies = Map[String, String]()
 val headers = Map[String, List[String]]()
 
-LOG.info("renderResourceListing camel -> {}", camel)
 if (camel != null) {
   val f = new SpecFilter
   val listings = RestApiListingCache.listing(camel, 
swaggerConfig).map(specs => {
@@ -123,7 +121,7 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
 List(),
 swaggerConfig.info
   )
-  LOG.info("renderResourceListing write response -> {}", resourceListing)
+  LOG.debug("renderResourceListing write response -> {}", resourceListing)
   
response.getOutputStream.write(JsonSerializer.asJson(resourceListing).getBytes("utf-8"))
 } else {
   response.setStatus(204)
@@ -134,6 +132,8 @@ class RestSwaggerApiDeclarationServlet extends HttpServlet {
* Renders the api listing of a single resource
*/
   def renderApiDeclaration(request: HttpServletRequest, response: 
HttpServletResponse) = {
+LOG.trace("renderApiDeclaration")
+
 val route = request.getPathInfo
 val docRoot = request.getPathInfo
 val f = new SpecFilter
@@ -142,7 +142,6 @@ class RestSwagger

[02/11] git commit: Merge branch 'master' into swagger

2014-08-10 Thread davsclaus
Merge branch 'master' into swagger


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

Branch: refs/heads/master
Commit: 5595ed626fb1c1589c5b584285db41f5a9ce0e69
Parents: cfe0909 625eb8d
Author: Claus Ibsen 
Authored: Fri Aug 8 09:58:46 2014 +0200
Committer: Claus Ibsen 
Committed: Fri Aug 8 09:58:46 2014 +0200

--
 apache-camel/pom.xml|   4 +
 .../src/main/descriptors/common-bin.xml |   1 +
 camel-core/pom.xml  |  44 +--
 .../java/org/apache/camel/CamelContext.java |  13 +-
 .../src/main/java/org/apache/camel/Route.java   |   1 +
 .../management/mbean/CamelOpenMBeanTypes.java   |  16 +-
 .../mbean/ManagedRestRegistryMBean.java |  32 +++
 .../org/apache/camel/builder/RouteBuilder.java  |   6 +-
 .../camel/component/rest/RestComponent.java |  24 +-
 .../camel/component/rest/RestEndpoint.java  |  96 ++-
 .../apache/camel/impl/DefaultCamelContext.java  |  14 +-
 .../apache/camel/impl/DefaultRestRegistry.java  | 181 +
 .../apache/camel/impl/DefaultRouteContext.java  |   5 +
 .../camel/impl/ScheduledPollConsumer.java   |   2 +-
 .../DefaultManagementLifecycleStrategy.java |   4 +
 .../management/mbean/ManagedRestRegistry.java   |  83 ++
 .../model/rest/RestConfigurationDefinition.java |  47 
 .../apache/camel/model/rest/RestDefinition.java |  84 +++---
 .../camel/model/rest/RestHostNameResolver.java  |  28 ++
 .../camel/model/rest/RestsDefinition.java   |   2 +-
 .../org/apache/camel/spi/RestConfiguration.java |  54 
 .../apache/camel/spi/RestConsumerFactory.java   |   5 +-
 .../java/org/apache/camel/spi/RestRegistry.java | 134 +
 .../java/org/apache/camel/util/HostUtils.java   | 119 
 .../org/apache/camel/model/rest/jaxb.index  |   1 +
 .../rest/DummyRestConsumerFactory.java  |   9 +-
 .../rest/FromRestExplicitComponentTest.java |   2 +-
 .../rest/FromRestGetEmbeddedRouteTest.java  |   4 +-
 .../component/rest/FromRestGetEndPathTest.java  |   4 +-
 .../camel/component/rest/FromRestGetTest.java   |   4 +-
 .../component/rest/FromRestUriPrefixTest.java   |  12 +-
 .../impl/MultipleLifecycleStrategyTest.java |   2 +-
 .../ManagedFromRestGetEmbeddedRouteTest.java|   4 +-
 .../management/ManagedFromRestGetTest.java  |   4 +-
 ...roducerRouteAddRemoveRegisterAlwaysTest.java |   6 +-
 .../management/ManagedRestRegistryTest.java |  98 +++
 .../management/ManagedRouteAddRemoveTest.java   |  42 +--
 .../apache/camel/model/XmlRestParseTest.java|   2 +-
 .../org/apache/camel/model/simpleRest.xml   |   2 +-
 .../camel/blueprint/BlueprintJaxbRestTest.java  |   4 +-
 .../src/test/resources/test-rest.xml|   4 +-
 .../camel/component/jdbc/JdbcProducer.java  |  16 +-
 ...ucerOutputTypeSelectListOutputClassTest.java |  63 +
 .../component/jetty/JettyHttpComponent.java |  25 +-
 ...JettyRestServletResolveConsumerStrategy.java |  79 +-
 .../jetty/rest/RestPathMatchingTest.java|  84 --
 .../jms/DefaultJmsMessageListenerContainer.java |  37 ++-
 .../jms/DefaultQueueBrowseStrategy.java |  23 ++
 .../camel/component/jms/JmsQueueEndpoint.java   |   6 +-
 .../component/jms/QueueBrowseStrategy.java  |   2 +
 .../ExclusiveQueueMessageListenerContainer.java |   3 +-
 .../SharedQueueMessageListenerContainer.java|   5 +-
 .../jms/reply/TemporaryQueueReplyManager.java   |   3 +-
 .../camel/component/jms/CamelJmsTestHelper.java |  24 +-
 ...uestReplyTempQueueMultipleConsumersTest.java |   2 +-
 .../camel/component/jms/JmsSelectorInTest.java  |   6 +-
 .../component/jms/JmsTransactedRouteTest.java   |   2 +-
 .../component/jms/ManagedJmsEndpointTest.java   |   2 +-
 .../JmsBlockedAsyncRoutingEngineTest.java   |   2 +-
 .../jms/issues/JmsTXForceShutdownIssueTest.xml  |   3 +-
 ...nErrorHandlerRedeliveryDelayTest-context.xml |   2 +-
 .../org/apache/camel/component/jms/spring.xml   |   2 +-
 .../jms/tx/AbstractTransactionTest.xml  |   4 +-
 .../tx/ActiveMQWithoutTransactionManager.xml|   2 +-
 .../jms/tx/JMSTransactionErrorHandlerTest.xml   |   2 +-
 ...MSTransactionIsTransactedRedeliveredTest.xml |   2 +-
 .../jms/tx/JMSTransactionRollbackTest.xml   |   2 +-
 .../JMSTransactionThrottlingRoutePolicyTest.xml |   2 +-
 .../jms/tx/JMSTransactionalClientTest.xml   |   2 +-
 .../JMSTransactionalClientWithRollbackTest.xml  |   2 +-
 .../jms/tx/JMXTXUseOriginalBodyTest.xml |   2 +-
 ...TXUseOriginalBodyWithDLCErrorHandlerTest.xml |   2 +-
 ...XTXUseOriginalBodyWithTXErrorHandlerTest.xml |   2 +-
 .../jms/tx/JmsToJmsTransactedSecurityTest.xml   |   2 +-
 .../component/jms/tx/JmsToJmsTransactedTest.xml |   2 +-
 

[11/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/50e8ed77
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/50e8ed77
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/50e8ed77

Branch: refs/heads/master
Commit: 50e8ed779883ced56c3897029848f98b80a6d0cc
Parents: 4252f65
Author: Claus Ibsen 
Authored: Sun Aug 10 11:41:11 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 11:41:11 2014 +0200

--
 .../src/main/webapp/WEB-INF/web.xml | 22 +---
 1 file changed, 14 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/50e8ed77/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
--
diff --git 
a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml 
b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
index e0c8151..7fd5d5f 100755
--- a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/WEB-INF/web.xml
@@ -47,13 +47,14 @@
 3
   
 
+  
   
   
 ApiDeclarationServlet
 
org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet
 2
 
-  swagger.api.basepath
+  base.path
   http://localhost:8080/api-docs
 
 
@@ -62,20 +63,25 @@
 
 
   api.title
-  Camel Rest Example with Swagger
+  User Services
+
+
+  api.description
+  Camel Rest Example with Swagger that provides an User REST 
service
 
   
 
-  
-  
-CamelServlet
-/rest/*
-  
-
   
   
 ApiDeclarationServlet
 /api-docs/*
   
+  
+
+  
+  
+CamelServlet
+/rest/*
+  
 
 
\ No newline at end of file



[05/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/a578af93
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a578af93
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a578af93

Branch: refs/heads/master
Commit: a578af9375b7ab86737505858801cc79362f5560
Parents: 7aa0b4a
Author: Claus Ibsen 
Authored: Sat Aug 9 10:35:20 2014 +0200
Committer: Claus Ibsen 
Committed: Sat Aug 9 11:06:32 2014 +0200

--
 .../component/swagger/RestSwaggerReader.scala   | 194 +++
 .../swagger/DummyRestConsumerFactory.java   |  48 +
 .../swagger/RestSwaggerReaderTest.java  |  38 ++--
 3 files changed, 182 insertions(+), 98 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/a578af93/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 c8e84a7..2b57013 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
@@ -6,7 +6,7 @@
  * (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
+ * 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,
@@ -16,109 +16,137 @@
  */
 package org.apache.camel.component.swagger
 
-import org.apache.camel.model.rest.{VerbDefinition, RestDefinition}
+import java.util.Locale
+
 import com.wordnik.swagger.config.SwaggerConfig
 import com.wordnik.swagger.model.{ApiDescription, Operation, ApiListing}
-import org.slf4j.LoggerFactory
 import com.wordnik.swagger.core.util.ModelUtil
 import com.wordnik.swagger.core.SwaggerSpec
+
+import org.apache.camel.model.rest.{VerbDefinition, RestDefinition}
+import org.apache.camel.util.FileUtil
+ import org.slf4j.LoggerFactory
+
 import scala.collection.mutable.ListBuffer
-import java.util.Locale
 
-// to iterate using for loop
+// to iterate Java list using for loop
 import scala.collection.JavaConverters._
 
 class RestSwaggerReader {
 
   private val LOG = LoggerFactory.getLogger(classOf[RestSwaggerReader])
 
+  def buildUrl(path1: String, path2: String): String = {
+val s1 = FileUtil.stripTrailingSeparator(path1)
+val s2 = FileUtil.stripLeadingSeparator(path2)
+if (s1 != null && s2 != null) {
+  s1 + "/" + s2
+} else if (path1 != null) {
+  path1
+} else {
+  path2
+}
+  }
+
   def read(rest: RestDefinition, config: SwaggerConfig): Option[ApiListing] = {
 
-val api = rest.getPath
-if (api != null) {
-  val fullPath = {
-if (api.startsWith("/")) api.substring(1)
-else api
+val resourcePath = rest.getPath
+
+// create a list of apis
+val apis = new ListBuffer[ApiDescription]
+
+// used during gathering of apis
+val operations = new ListBuffer[Operation]
+var path: String = null
+
+// must sort the verbs by uri so we group them together when an uri has 
multiple operations
+// TODO: we want to sort /{xx} first, so we may need some regexp matching 
to trigger sorting them before non {}
+// TODO: and then 2nd sort by http method
+var list = rest.getVerbs.asScala
+list = list.sortBy(v => v.getUri match {
+  case v: Any => v
+  case _ => ""
+})
+
+for (verb: VerbDefinition <- list) {
+
+  if (verb.getUri != path && operations.size > 0) {
+// restart
+apis += ApiDescription(
+  buildUrl(resourcePath, path),
+  Some(""),
+  operations.toList)
+operations.clear()
   }
-  val (resourcePath, subpath) = {
-if (fullPath.indexOf("/") > 0) {
-  val pos = fullPath.indexOf("/")
-  ("/" + fullPath.substring(0, pos), fullPath.substring(pos))
-}
-else ("/", fullPath)
+
+  path = verb.getUri
+  var method = verb.asVerb().toUpperCase(Locale.US)
+
+  var responseType = verb.getOutType match {
+case e: String => e
+case _ => "java.lang.Void"
   }
 
-  LOG.debug("read routes from classes: %s, %s".format(resourcePath, 
subpath))
-
-  val operations = new ListBuffer[Operation]
-
-  val list = rest.getVerbs.asScala
-  for (verb: VerbDefinition <- list) {
-
-var method = 

[04/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/7aa0b4a1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7aa0b4a1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7aa0b4a1

Branch: refs/heads/master
Commit: 7aa0b4a1613eec32af23c0a230fb8937b695802f
Parents: 1a6fe60
Author: Claus Ibsen 
Authored: Sat Aug 9 09:54:16 2014 +0200
Committer: Claus Ibsen 
Committed: Sat Aug 9 09:54:16 2014 +0200

--
 .../RestSwaggerApiDeclarationServlet.scala  | 30 ++--
 .../component/swagger/RestSwaggerReader.scala   | 30 ++--
 .../swagger/RestSwaggerReaderTest.java  |  6 ++--
 3 files changed, 33 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/7aa0b4a1/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 ca7106b..0cb985f 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
@@ -1,17 +1,3 @@
-package org.apache.camel.component.swagger
-
-import com.wordnik.swagger.servlet.listing.{ApiListingCache, 
ApiDeclarationServlet}
-import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
-import com.wordnik.swagger.core.filter.SpecFilter
-import com.wordnik.swagger.config.{ConfigFactory, FilterFactory}
-import com.wordnik.swagger.model.{ResourceListing, ApiListingReference}
-import com.wordnik.swagger.core.util.JsonSerializer
-import javax.servlet.ServletConfig
-import org.springframework.web.context.support.WebApplicationContextUtils
-import org.springframework.web.context.WebApplicationContext
-import org.apache.camel.CamelContext
-import org.slf4j.LoggerFactory
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,7 +6,7 @@ import org.slf4j.LoggerFactory
  * (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
+ *  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,
@@ -28,6 +14,20 @@ import org.slf4j.LoggerFactory
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.camel.component.swagger
+
+import com.wordnik.swagger.servlet.listing.{ApiListingCache, 
ApiDeclarationServlet}
+import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
+import com.wordnik.swagger.core.filter.SpecFilter
+import com.wordnik.swagger.config.{ConfigFactory, FilterFactory}
+import com.wordnik.swagger.model.{ResourceListing, ApiListingReference}
+import com.wordnik.swagger.core.util.JsonSerializer
+import javax.servlet.ServletConfig
+import org.springframework.web.context.support.WebApplicationContextUtils
+import org.springframework.web.context.WebApplicationContext
+import org.apache.camel.CamelContext
+import org.slf4j.LoggerFactory
+
 class RestSwaggerApiDeclarationServlet extends ApiDeclarationServlet {
 
   private val LOG = 
LoggerFactory.getLogger(classOf[RestSwaggerApiDeclarationServlet])

http://git-wip-us.apache.org/repos/asf/camel/blob/7aa0b4a1/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 ff05501..c8e84a7 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
@@ -1,17 +1,3 @@
-package org.apache.camel.component.swagger
-
-import org.apache.camel.model.rest.{VerbDefinition, RestDefinition}
-import com.wordnik.swagger.config.SwaggerConfig
-import com.wordnik.swagger.model.{ApiDescription, Operation, ApiListing}
-import org.slf4j.LoggerFactory
-import com.wordnik.swagger.core.util

[06/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/b234476a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b234476a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b234476a

Branch: refs/heads/master
Commit: b234476abf46ddf1f109fe3fbc1b6395c0ae5228
Parents: a578af9
Author: Claus Ibsen 
Authored: Sat Aug 9 11:51:52 2014 +0200
Committer: Claus Ibsen 
Committed: Sat Aug 9 12:31:18 2014 +0200

--
 .../component/swagger/RestApiListingCache.scala |  54 +
 .../RestSwaggerApiDeclarationServlet.scala  | 117 +--
 .../component/swagger/RestSwaggerReader.scala   |  30 ++---
 .../src/main/webapp/WEB-INF/web.xml |  34 +++---
 4 files changed, 164 insertions(+), 71 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/b234476a/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
new file mode 100644
index 000..494e620
--- /dev/null
+++ 
b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestApiListingCache.scala
@@ -0,0 +1,54 @@
+/**
+ * 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.swagger
+
+import com.wordnik.swagger.core.util.ReaderUtil
+import com.wordnik.swagger.config.SwaggerConfig
+import org.apache.camel.CamelContext
+import com.wordnik.swagger.model.{Operation, ApiListing}
+import scala.collection.mutable.ListBuffer
+
+// to iterate Java list using for loop
+import scala.collection.JavaConverters._
+
+object RestApiListingCache extends ReaderUtil {
+
+  var cache: Option[Map[String, ApiListing]] = None
+  val reader = new RestSwaggerReader()
+
+  def listing(camel: CamelContext, config: SwaggerConfig): Option[Map[String, 
ApiListing]] = {
+cache.orElse {
+  val listings = new ListBuffer[ApiListing]
+
+  val rests = camel.getRestDefinitions.asScala
+  for (rest <- rests) {
+// TODO: this can be nicer
+val option = reader.read(rest, config)
+if (option.get != null) {
+  listings += option.get
+}
+  }
+
+  if (listings.size > 0) {
+val mergedListings = groupByResourcePath(listings.toList)
+cache = Some(mergedListings.map(m => (m.resourcePath, m)).toMap)
+  }
+  cache
+}
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b234476a/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 0cb985f..11af449 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
@@ -16,55 +16,99 @@
  */
 package org.apache.camel.component.swagger
 
-import com.wordnik.swagger.servlet.listing.{ApiListingCache, 
ApiDeclarationServlet}
-import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
+import javax.servlet.http.{HttpServlet, HttpServletResponse, 
HttpServletRequest}
+import javax.servlet.ServletConfig
+
+import com.wordnik.swagger.core.SwaggerContext
 import com.wordnik.swagger.core.filter.SpecFilter
-import com.wordnik.swagger.config.{ConfigFactory, FilterFactory}
-import com.wordnik.swagger.model.{ResourceListing, ApiListingReference}
 import com.wordnik.swagger.core.util.JsonSerializer
-import ja

[01/11] git commit: Early experiment with camel-swagger

2014-08-10 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 625eb8d76 -> 50e8ed779


Early experiment with camel-swagger


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

Branch: refs/heads/master
Commit: cfe0909a2b6670ba6b0134dd0fa59458023f4025
Parents: d98a45e
Author: Claus Ibsen 
Authored: Wed Jul 30 13:57:30 2014 +0200
Committer: Claus Ibsen 
Committed: Wed Jul 30 13:57:56 2014 +0200

--
 components/camel-swagger/pom.xml|  78 +++
 .../apache/camel/component/swagger/MyDemo.java  |  29 +++
 .../component/swagger/MyDynamicCompiler.java|  95 +
 .../src/main/resources/META-INF/LICENSE.txt | 203 +++
 .../src/main/resources/META-INF/NOTICE.txt  |  11 +
 .../apache/camel/component/swagger/TestMe.java  |  47 +
 .../src/test/resources/log4j.properties |  43 
 7 files changed, 506 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/cfe0909a/components/camel-swagger/pom.xml
--
diff --git a/components/camel-swagger/pom.xml b/components/camel-swagger/pom.xml
new file mode 100644
index 000..9e2710b
--- /dev/null
+++ b/components/camel-swagger/pom.xml
@@ -0,0 +1,78 @@
+
+
+http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  4.0.0
+
+  
+org.apache.camel
+components
+2.14-SNAPSHOT
+  
+
+  camel-swagger
+  bundle
+  Camel :: Swagger
+  Camel Swagger support
+
+  
+
org.apache.camel.component.swgger.*
+
org.apache.camel.spi.ComponentResolver;component=swagger
+  
+
+  
+
+
+  org.apache.camel
+  camel-core
+
+
+
+  com.wordnik
+  swagger-annotations
+  1.3.7
+
+
+  com.wordnik
+  swagger-jaxrs_2.10
+  1.3.7
+
+
+
+
+  org.apache.camel
+  camel-test
+  test
+
+
+  org.apache.camel
+  camel-jetty
+  test
+
+
+  junit
+  junit
+  test
+
+
+  org.slf4j
+  slf4j-log4j12
+  test
+
+  
+
+

http://git-wip-us.apache.org/repos/asf/camel/blob/cfe0909a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
--
diff --git 
a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
 
b/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
new file mode 100644
index 000..ccbd9f9
--- /dev/null
+++ 
b/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.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.swagger;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Api("foo")
+public class MyDemo {
+
+@ApiOperation(value = "hi", produces = "text/plain", httpMethod = "POST")
+public String doSomething(String hi) {
+return "Hello " + hi;
+}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/cfe0909a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDynamicCompiler.java
--
diff --git 
a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDynamicCompiler.java
 
b/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDynamicCompiler.java
new file mode 100644
index 000..30e6996
--- /dev/null
+++ 
b/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDynamicCompiler.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE fi

[07/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/8b3d6450
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8b3d6450
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8b3d6450

Branch: refs/heads/master
Commit: 8b3d64503ddedb391e56102538992c81a0416edf
Parents: b234476
Author: Claus Ibsen 
Authored: Sun Aug 10 08:50:10 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 08:50:10 2014 +0200

--
 examples/camel-example-servlet-rest-tomcat/README.txt| 3 +++
 .../src/main/webapp/index.html   | 8 
 2 files changed, 11 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/8b3d6450/examples/camel-example-servlet-rest-tomcat/README.txt
--
diff --git a/examples/camel-example-servlet-rest-tomcat/README.txt 
b/examples/camel-example-servlet-rest-tomcat/README.txt
index 81eac72..48b7fdd 100644
--- a/examples/camel-example-servlet-rest-tomcat/README.txt
+++ b/examples/camel-example-servlet-rest-tomcat/README.txt
@@ -18,6 +18,9 @@ deploy folder of Apache Tomcat.
 And then hit this url from a web browser which has further instructions
   http://localhost:8080/camel-example-servlet-rest-tomcat
 
+Included in this example is an api browser using Swagger. You can see the API 
from this url:
+  http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs
+
 You can also try the example from Maven using
mvn jetty:run
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8b3d6450/examples/camel-example-servlet-rest-tomcat/src/main/webapp/index.html
--
diff --git 
a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/index.html 
b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/index.html
index ac6b54b..1ea929a 100644
--- a/examples/camel-example-servlet-rest-tomcat/src/main/webapp/index.html
+++ b/examples/camel-example-servlet-rest-tomcat/src/main/webapp/index.html
@@ -55,6 +55,14 @@ From the command shell you can use curl to access the 
service as shown below:
 
 
 
+This example offers an API browser using Swagger which is accessible from the 
following link
+
+  api-docs - overview of the apis from the REST 
services
+  api-docs/user - api of the user REST 
service
+
+
+
+
 If you hit any problems please let us know on the
 http://camel.apache.org/discussion-forums.html";>Camel Forums
 



[10/11] git commit: Merge branch 'swagger'

2014-08-10 Thread davsclaus
Merge branch 'swagger'


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

Branch: refs/heads/master
Commit: 4252f653a3a53ceda8fadbf25dae123fb8e4e086
Parents: 625eb8d a53b2da
Author: Claus Ibsen 
Authored: Sun Aug 10 11:17:22 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 11:17:22 2014 +0200

--
 apache-camel/pom.xml|   4 +
 .../src/main/descriptors/common-bin.xml |   1 +
 components/camel-swagger/pom.xml| 158 +++
 .../src/main/resources/META-INF/LICENSE.txt | 203 +++
 .../src/main/resources/META-INF/NOTICE.txt  |  11 +
 .../component/swagger/RestApiListingCache.scala |  55 +
 .../RestSwaggerApiDeclarationServlet.scala  | 164 +++
 .../component/swagger/RestSwaggerReader.scala   | 194 ++
 .../swagger/DummyRestConsumerFactory.java   |  48 +
 .../swagger/RestSwaggerReaderTest.java  |  75 +++
 .../src/test/resources/log4j.properties |  42 
 components/pom.xml  |   1 +
 .../README.txt  |   3 +
 .../camel-example-servlet-rest-tomcat/pom.xml   |  35 +++-
 .../camel/example/rest/UserRouteBuilder.java|   5 +
 .../src/main/resources/camel-config.xml |   6 +-
 .../src/main/resources/log4j.properties |   2 +
 .../src/main/webapp/WEB-INF/web.xml |  26 +++
 .../src/main/webapp/index.html  |   8 +
 parent/pom.xml  |   6 +
 20 files changed, 1045 insertions(+), 2 deletions(-)
--




[09/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/a53b2da7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a53b2da7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a53b2da7

Branch: refs/heads/master
Commit: a53b2da7716a9a6fd2ff232364195435e604cfac
Parents: 3f821b0
Author: Claus Ibsen 
Authored: Sun Aug 10 11:16:57 2014 +0200
Committer: Claus Ibsen 
Committed: Sun Aug 10 11:16:57 2014 +0200

--
 apache-camel/pom.xml | 4 
 apache-camel/src/main/descriptors/common-bin.xml | 1 +
 components/camel-swagger/pom.xml | 7 ---
 .../camel/component/swagger/RestSwaggerReaderTest.java   | 8 ++--
 components/camel-swagger/src/test/resources/log4j.properties | 7 +++
 components/pom.xml   | 1 +
 .../src/main/resources/log4j.properties  | 3 ++-
 parent/pom.xml   | 6 ++
 8 files changed, 27 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/a53b2da7/apache-camel/pom.xml
--
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index acfeb72..781f831 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -616,6 +616,10 @@
 
 
   org.apache.camel
+  camel-swagger
+
+
+  org.apache.camel
   camel-sql
 
 

http://git-wip-us.apache.org/repos/asf/camel/blob/a53b2da7/apache-camel/src/main/descriptors/common-bin.xml
--
diff --git a/apache-camel/src/main/descriptors/common-bin.xml 
b/apache-camel/src/main/descriptors/common-bin.xml
index cef837d..a7ed332 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -171,6 +171,7 @@
 org.apache.camel:camel-stream
 org.apache.camel:camel-stringtemplate
 org.apache.camel:camel-syslog
+org.apache.camel:camel-swagger
 org.apache.camel:camel-tagsoup
 org.apache.camel:camel-test
 org.apache.camel:camel-test-blueprint

http://git-wip-us.apache.org/repos/asf/camel/blob/a53b2da7/components/camel-swagger/pom.xml
--
diff --git a/components/camel-swagger/pom.xml b/components/camel-swagger/pom.xml
index fe978c8..e55c542 100644
--- a/components/camel-swagger/pom.xml
+++ b/components/camel-swagger/pom.xml
@@ -44,6 +44,7 @@
   camel-core
 
 
+
 
   org.springframework
   spring-web
@@ -52,17 +53,17 @@
 
   com.wordnik
   swagger-annotations
-  1.3.7
+  ${swagger-version}
 
 
   com.wordnik
   swagger-jaxrs_2.10
-  1.3.7
+  ${swagger-version}
 
 
   com.wordnik
   swagger-servlet_2.10
-  1.3.7
+  ${swagger-version}
 
 
 

http://git-wip-us.apache.org/repos/asf/camel/blob/a53b2da7/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/RestSwaggerReaderTest.java
--
diff --git 
a/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/RestSwaggerReaderTest.java
 
b/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/RestSwaggerReaderTest.java
index d1be9c9..95b4da8 100644
--- 
a/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/RestSwaggerReaderTest.java
+++ 
b/components/camel-swagger/src/test/java/org/apache/camel/component/swagger/RestSwaggerReaderTest.java
@@ -61,9 +61,13 @@ public class RestSwaggerReaderTest extends CamelTestSupport {
 ApiListing listing = option.get();
 assertNotNull(listing);
 
-System.out.println(listing);
 String json = JsonSerializer.asJson(listing);
-System.out.println(json);
+log.info(json);
+
+
assertTrue(json.contains("\"basePath\":\"http://localhost:8080/api\"";));
+assertTrue(json.contains("\"resourcePath\":\"/hello\""));
+assertTrue(json.contains("\"method\":\"GET\""));
+assertTrue(json.contains("\"nickname\":\"getHelloHi\""));
 
 context.stop();
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a53b2da7/components/camel-swagger/src/test/resources/log4j.properties
--
diff --git a/components/camel-swagger/src/test/resources/log4j.properties 
b/components/camel-swagger/src/test/resources/log4j.properties
index 89fc1bd..fc97cab 100644
--- a/components/camel-swagger/src/test/resources/log4j.properties
+++ b

[03/11] git commit: Rest DSL. camel-swagger work in progress.

2014-08-10 Thread davsclaus
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/1a6fe606
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a6fe606
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a6fe606

Branch: refs/heads/master
Commit: 1a6fe606c48c3a33aa2131345e0c9a684ac58b1b
Parents: 5595ed6
Author: Claus Ibsen 
Authored: Fri Aug 8 17:29:33 2014 +0200
Committer: Claus Ibsen 
Committed: Fri Aug 8 17:29:33 2014 +0200

--
 components/camel-swagger/pom.xml|  85 -
 .../apache/camel/component/swagger/MyDemo.java  |  29 -
 .../component/swagger/MyDynamicCompiler.java|  95 --
 .../RestSwaggerApiDeclarationServlet.scala  | 122 ++
 .../component/swagger/RestSwaggerReader.scala   | 125 +++
 .../swagger/RestSwaggerReaderTest.java  |  63 ++
 .../apache/camel/component/swagger/TestMe.java  |  47 ---
 .../camel-example-servlet-rest-tomcat/pom.xml   |  35 +-
 .../camel/example/rest/UserRouteBuilder.java|   5 +
 .../src/main/resources/camel-config.xml |   6 +-
 .../src/main/resources/log4j.properties |   1 +
 .../src/main/webapp/WEB-INF/web.xml |  34 +
 12 files changed, 471 insertions(+), 176 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/1a6fe606/components/camel-swagger/pom.xml
--
diff --git a/components/camel-swagger/pom.xml b/components/camel-swagger/pom.xml
index 9e2710b..fe978c8 100644
--- a/components/camel-swagger/pom.xml
+++ b/components/camel-swagger/pom.xml
@@ -15,7 +15,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   4.0.0
 
   
@@ -30,8 +31,10 @@
   Camel Swagger support
 
   
-
org.apache.camel.component.swgger.*
-
org.apache.camel.spi.ComponentResolver;component=swagger
+
+  scala.*;version="[2.10,2.12)"
+
+
org.apache.camel.component.swagger.*
   
 
   
@@ -42,6 +45,11 @@
 
 
 
+  org.springframework
+  spring-web
+
+
+
   com.wordnik
   swagger-annotations
   1.3.7
@@ -51,6 +59,18 @@
   swagger-jaxrs_2.10
   1.3.7
 
+
+  com.wordnik
+  swagger-servlet_2.10
+  1.3.7
+
+
+
+  javax.servlet
+  servlet-api
+  2.5
+  provided
+
 
 
 
@@ -75,4 +95,63 @@
 
   
 
+  
+
+  
+
+
+  org.eclipse.m2e
+  lifecycle-mapping
+  ${lifecycle-mapping-version}
+  
+
+  
+
+  
+net.alchim31.maven
+scala-maven-plugin
+${scala-maven-plugin-version}
+
+  compile
+  testCompile
+
+  
+  
+
+  
+
+  
+
+  
+
+  
+
+
+src/main/scala
+
+
+  
+net.alchim31.maven
+scala-maven-plugin
+  
+  
+org.apache.maven.plugins
+maven-eclipse-plugin
+
+  
+ch.epfl.lamp.sdt.core.scalanature
+org.eclipse.jdt.core.javanature
+  
+  
+ch.epfl.lamp.sdt.core.scalabuilder
+  
+  
+
ch.epfl.lamp.sdt.launching.SCALA_CONTAINER
+
org.eclipse.jdt.launching.JRE_CONTAINER
+  
+
+  
+
+  
+
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1a6fe606/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
--
diff --git 
a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
 
b/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
deleted file mode 100644
index ccbd9f9..000
--- 
a/components/camel-swagger/src/main/java/org/apache/camel/component/swagger/MyDemo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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 copyr

[CONF] Apache Camel > Swagger

2014-08-10 Thread Claus Ibsen (Confluence)














  


Claus Ibsen edited the page:
 


Swagger   






...



 div








class
confluenceTableSmall


 









 Option 
 Type 
 Description 


swagger.version
String
Swagger spec version. Is default 1.2.


base.path  
String
Required: To setup the base path where the API is available


api.version
String
The version of the api. Defaults to Is default 0.0.0.


api.path
String
   

[CONF] Apache Camel > Swagger

2014-08-10 Thread Claus Ibsen (Confluence)














  


Claus Ibsen created a page:
 


Swagger   





Swagger Component
 Available as of Camel 2.14 
The  Rest DSL can be integrated with the camel-swagger module which is used for exposing the REST services and their APIs using Swagger.
Maven users will need to add the following dependency to their pom.xml for this component:



org.apache.camel
camel-swagger
x.x.x





Using
To use this you need to configure the org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet in the WEB-INF/web.xml file as shown below:

Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20

Options
The org.apache.camel.component.swagger.RestSwaggerApiDeclarationServlet supports the following options which can be configured as context-param in the web.xml file.





 Option 
 Type 
 Description 


base.path  
String
Required: To setup the base path where the API is available


api.version
String
The version of the api. Defaults to 0.0.0


api.path
String
Path of the api


api.title
String
Required. The title of the application.


api.description
String
  

[CONF] Apache Camel > Rest DSL

2014-08-10 Thread Claus Ibsen (Confluence)














  


Claus Ibsen edited the page:
 


Rest DSL   






...
Any Apache Camel component can integrate with the Rest DSL if they can be used as a REST service (eg as a REST consumer in Camel lingo). To integrate with the Rest DSL, then the component should implement the org.apache.camel.spi.RestConsumerFactory. The Rest DSL will then invoke the createConsumer method when it setup the Camel routes from the defined DSL. The component should then implement logic to create a Camel consumer that exposes the REST services based on the given parameters, such as path, verb, and other options. For example see the source code for camel-restlet, camel-spark-rest.
 Swagger API 
 The Rest DSL supports Swagger by the camel-swagger module. See more details at  Swagger and the camel-example-servlet-rest-tomcat example from the Apache Camel distribution. 
See Also
 DSL 
 Rest 
 Swagger 
 Spark-rest 
 How do I import rests from other XML files 






 View Online  · Like  · View Changes  
 Stop watching space  · Manage Notifications  


 


 


  This message was sent by Atlassian Confluence 5.0.3, Team Collaboration Software