You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2017/03/28 20:45:03 UTC

[2/2] camel git commit: CAMEL-11006 Auto generate REST DSL for Camel fr...

CAMEL-11006 Auto generate REST DSL for Camel fr...

...om Swagger2.0/OAI specification

This is initial work on REST DSL code|object generation from Swagger
specification.

Entry point to the implementation is RestDslGenerator::to...(...)
methods. Several options are provided for generating source files:
 - for code generation in Maven plugin ones accepting Path or Appendable
   should be suitable
 - for generation in Annotation Processing ones accepting Filer are more
   appropriate
 - and for generation of the object graph in runtime the one accepting
   CamelContext is provided

Both the source code and object graph implementation depend on a
CodeEmitter implementation: one relying on reflection
(RestDefinitionEmitter) is used to generate the object graph, and the
one generating the source code for the RouteBuilder::configure method
body using the javapoet library (MethodBodySourceCodeEmitter).

CodeEmitter is driven by two visitor pattern implementations one
for processing path elements of the specification (RestDslPathGenerator)
and one for processing operation elements of he specification
(RestDslOperationGenerator). Both can be further adapted to support more
of the Swagger specification. I believe they map the currently used /
relevant parts of the Swagger specification covered by REST DSL.

Example of usage:

    RestDslGenerator.toPath(swagger)
        .withClassName("MyRestRoute")
        .withPackageName("com.example")
        .withIndent("\t")
        .generate(Paths.get("src", "generated"));


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

Branch: refs/heads/master
Commit: 29d3f1c113e9706199e88b2f52d900195eee4536
Parents: ceeab4b
Author: Zoran Regvart <zr...@apache.org>
Authored: Sun Mar 26 11:32:16 2017 +0200
Committer: Zoran Regvart <zr...@apache.org>
Committed: Tue Mar 28 22:44:45 2017 +0200

----------------------------------------------------------------------
 parent/pom.xml                                  |   1 +
 tooling/pom.xml                                 |   1 +
 .../swagger-rest-dsl-generator/petstore.json    |   1 +
 tooling/swagger-rest-dsl-generator/pom.xml      |  70 +++++
 .../generator/swagger/AppendableGenerator.java  |  38 +++
 .../camel/generator/swagger/CodeEmitter.java    |  25 ++
 .../camel/generator/swagger/FilerGenerator.java |  40 +++
 .../swagger/MethodBodySourceCodeEmitter.java    | 166 +++++++++++
 .../generator/swagger/OperationVisitor.java     | 122 ++++++++
 .../camel/generator/swagger/PathGenerator.java  |  39 +++
 .../camel/generator/swagger/PathVisitor.java    |  43 +++
 .../swagger/RestDefinitionEmitter.java          |  99 +++++++
 .../swagger/RestDslDefinitionGenerator.java     |  40 +++
 .../generator/swagger/RestDslGenerator.java     |  86 ++++++
 .../swagger/RestDslSourceCodeGenerator.java     | 137 +++++++++
 .../MethodBodySourceCodeEmitterTest.java        |  57 ++++
 .../swagger/RestDefinitionEmitterTest.java      |  70 +++++
 .../generator/swagger/RestDslGeneratorTest.java |  73 +++++
 .../src/test/resources/MyRestRoute.txt          | 281 +++++++++++++++++++
 .../src/test/resources/SwaggerPetstore.txt      | 281 +++++++++++++++++++
 20 files changed, 1670 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8e3dfd5..11a2144 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -310,6 +310,7 @@
     <jnats-version>1.0</jnats-version>
     <javacc-maven-plugin-version>2.6</javacc-maven-plugin-version>
     <javacrumbs-version>0.22</javacrumbs-version>
+    <javapoet-version>1.8.0</javapoet-version>
     <javassist-bundle-version>3.12.1.GA_3</javassist-bundle-version>
     <javax.el-api-version>2.2.5</javax.el-api-version>
     <javax.el-version>2.2.5</javax.el-version>

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 4aeebed..c278afd 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -42,6 +42,7 @@
     <module>camel-route-parser</module>
     <module>maven</module>
     <module>camel-manual</module>
+    <module>swagger-rest-dsl-generator</module>
   </modules>
 
   <!-- profiles>

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/petstore.json
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/petstore.json b/tooling/swagger-rest-dsl-generator/petstore.json
new file mode 100644
index 0000000..816847f
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/petstore.json
@@ -0,0 +1 @@
+{"swagger":"2.0","info":{"description":"This is a sample server Petstore server.  You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).  For this sample, you can use the api key `special-key` to test the authorization filters.","version":"1.0.0","title":"Swagger Petstore","termsOfService":"http://swagger.io/terms/","contact":{"email":"apiteam@swagger.io"},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"host":"petstore.swagger.io","basePath":"/v2","tags":[{"name":"pet","description":"Everything about your Pets","externalDocs":{"description":"Find out more","url":"http://swagger.io"}},{"name":"store","description":"Access to Petstore orders"},{"name":"user","description":"Operations about user","externalDocs":{"description":"Find out more about our store","url":"http://swagger.io"}}],"schemes":["http"],"paths":{"/pet":{"post":{"tags":["pet"],"summary":"Add a ne
 w pet to the store","description":"","operationId":"addPet","consumes":["application/json","application/xml"],"produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Pet object that needs to be added to the store","required":true,"schema":{"$ref":"#/definitions/Pet"}}],"responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]},"put":{"tags":["pet"],"summary":"Update an existing pet","description":"","operationId":"updatePet","consumes":["application/json","application/xml"],"produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Pet object that needs to be added to the store","required":true,"schema":{"$ref":"#/definitions/Pet"}}],"responses":{"400":{"description":"Invalid ID supplied"},"404":{"description":"Pet not found"},"405":{"description":"Validation exception"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet
 /findByStatus":{"get":{"tags":["pet"],"summary":"Finds Pets by status","description":"Multiple status values can be provided with comma separated strings","operationId":"findPetsByStatus","produces":["application/xml","application/json"],"parameters":[{"name":"status","in":"query","description":"Status values that need to be considered for filter","required":true,"type":"array","items":{"type":"string","enum":["available","pending","sold"],"default":"available"},"collectionFormat":"multi"}],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},"400":{"description":"Invalid status value"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet/findByTags":{"get":{"tags":["pet"],"summary":"Finds Pets by tags","description":"Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.","operationId":"findPetsByTags","produces":["application/xml","application/json"],"parameters"
 :[{"name":"tags","in":"query","description":"Tags to filter by","required":true,"type":"array","items":{"type":"string"},"collectionFormat":"multi"}],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/Pet"}}},"400":{"description":"Invalid tag value"}},"security":[{"petstore_auth":["write:pets","read:pets"]}],"deprecated":true}},"/pet/{petId}":{"get":{"tags":["pet"],"summary":"Find pet by ID","description":"Returns a single pet","operationId":"getPetById","produces":["application/xml","application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet to return","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Pet"}},"400":{"description":"Invalid ID supplied"},"404":{"description":"Pet not found"}},"security":[{"api_key":[]}]},"post":{"tags":["pet"],"summary":"Updates a pet in the store with form data","descriptio
 n":"","operationId":"updatePetWithForm","consumes":["application/x-www-form-urlencoded"],"produces":["application/xml","application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet that needs to be updated","required":true,"type":"integer","format":"int64"},{"name":"name","in":"formData","description":"Updated name of the pet","required":false,"type":"string"},{"name":"status","in":"formData","description":"Updated status of the pet","required":false,"type":"string"}],"responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]},"delete":{"tags":["pet"],"summary":"Deletes a pet","description":"","operationId":"deletePet","produces":["application/xml","application/json"],"parameters":[{"name":"api_key","in":"header","required":false,"type":"string"},{"name":"petId","in":"path","description":"Pet id to delete","required":true,"type":"integer","format":"int64"}],"responses":{"400":{"description":"Invalid ID suppl
 ied"},"404":{"description":"Pet not found"}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/pet/{petId}/uploadImage":{"post":{"tags":["pet"],"summary":"uploads an image","description":"","operationId":"uploadFile","consumes":["multipart/form-data"],"produces":["application/json"],"parameters":[{"name":"petId","in":"path","description":"ID of pet to update","required":true,"type":"integer","format":"int64"},{"name":"additionalMetadata","in":"formData","description":"Additional data to pass to server","required":false,"type":"string"},{"name":"file","in":"formData","description":"file to upload","required":false,"type":"file"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiResponse"}}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}},"/store/inventory":{"get":{"tags":["store"],"summary":"Returns pet inventories by status","description":"Returns a map of status codes to quantities","operationId":"getInventory","pro
 duces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"object","additionalProperties":{"type":"integer","format":"int32"}}}},"security":[{"api_key":[]}]}},"/store/order":{"post":{"tags":["store"],"summary":"Place an order for a pet","description":"","operationId":"placeOrder","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"order placed for purchasing the pet","required":true,"schema":{"$ref":"#/definitions/Order"}}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Order"}},"400":{"description":"Invalid Order"}}}},"/store/order/{orderId}":{"get":{"tags":["store"],"summary":"Find purchase order by ID","description":"For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions","operationId":"getOrderById","produces":["application/xml","application/json"],"parameters":[{"name":"orderId",
 "in":"path","description":"ID of pet that needs to be fetched","required":true,"type":"integer","maximum":10.0,"minimum":1.0,"format":"int64"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/Order"}},"400":{"description":"Invalid ID supplied"},"404":{"description":"Order not found"}}},"delete":{"tags":["store"],"summary":"Delete purchase order by ID","description":"For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors","operationId":"deleteOrder","produces":["application/xml","application/json"],"parameters":[{"name":"orderId","in":"path","description":"ID of the order that needs to be deleted","required":true,"type":"integer","minimum":1.0,"format":"int64"}],"responses":{"400":{"description":"Invalid ID supplied"},"404":{"description":"Order not found"}}}},"/user":{"post":{"tags":["user"],"summary":"Create user","description":"This can only be done by the logged in user.","op
 erationId":"createUser","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"Created user object","required":true,"schema":{"$ref":"#/definitions/User"}}],"responses":{"default":{"description":"successful operation"}}}},"/user/createWithArray":{"post":{"tags":["user"],"summary":"Creates list of users with given input array","description":"","operationId":"createUsersWithArrayInput","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"List of user object","required":true,"schema":{"type":"array","items":{"$ref":"#/definitions/User"}}}],"responses":{"default":{"description":"successful operation"}}}},"/user/createWithList":{"post":{"tags":["user"],"summary":"Creates list of users with given input array","description":"","operationId":"createUsersWithListInput","produces":["application/xml","application/json"],"parameters":[{"in":"body","name":"body","description":"List of user obj
 ect","required":true,"schema":{"type":"array","items":{"$ref":"#/definitions/User"}}}],"responses":{"default":{"description":"successful operation"}}}},"/user/login":{"get":{"tags":["user"],"summary":"Logs user into the system","description":"","operationId":"loginUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"query","description":"The user name for login","required":true,"type":"string"},{"name":"password","in":"query","description":"The password for login in clear text","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"type":"string"},"headers":{"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"},"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"}}},"400":{"description":"Invalid username/password supplied"}}}},"/user/logout":{"get":{"tags":["user"],"summary":"Logs out current logged
  in user session","description":"","operationId":"logoutUser","produces":["application/xml","application/json"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/user/{username}":{"get":{"tags":["user"],"summary":"Get user by user name","description":"","operationId":"getUserByName","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"The name that needs to be fetched. Use user1 for testing. ","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/User"}},"400":{"description":"Invalid username supplied"},"404":{"description":"User not found"}}},"put":{"tags":["user"],"summary":"Updated user","description":"This can only be done by the logged in user.","operationId":"updateUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"name that need to be updated","required":t
 rue,"type":"string"},{"in":"body","name":"body","description":"Updated user object","required":true,"schema":{"$ref":"#/definitions/User"}}],"responses":{"400":{"description":"Invalid user supplied"},"404":{"description":"User not found"}}},"delete":{"tags":["user"],"summary":"Delete user","description":"This can only be done by the logged in user.","operationId":"deleteUser","produces":["application/xml","application/json"],"parameters":[{"name":"username","in":"path","description":"The name that needs to be deleted","required":true,"type":"string"}],"responses":{"400":{"description":"Invalid username supplied"},"404":{"description":"User not found"}}}}},"securityDefinitions":{"petstore_auth":{"type":"oauth2","authorizationUrl":"http://petstore.swagger.io/oauth/dialog","flow":"implicit","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}},"api_key":{"type":"apiKey","name":"api_key","in":"header"}},"definitions":{"Order":{"type":"object","properties":{
 "id":{"type":"integer","format":"int64"},"petId":{"type":"integer","format":"int64"},"quantity":{"type":"integer","format":"int32"},"shipDate":{"type":"string","format":"date-time"},"status":{"type":"string","description":"Order Status","enum":["placed","approved","delivered"]},"complete":{"type":"boolean","default":false}},"xml":{"name":"Order"}},"Category":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}},"xml":{"name":"Category"}},"User":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"username":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"phone":{"type":"string"},"userStatus":{"type":"integer","format":"int32","description":"User Status"}},"xml":{"name":"User"}},"Tag":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}},"xml":{"name":"Tag"}},"Pet":{"type":"object","required":["
 name","photoUrls"],"properties":{"id":{"type":"integer","format":"int64"},"category":{"$ref":"#/definitions/Category"},"name":{"type":"string","example":"doggie"},"photoUrls":{"type":"array","xml":{"name":"photoUrl","wrapped":true},"items":{"type":"string"}},"tags":{"type":"array","xml":{"name":"tag","wrapped":true},"items":{"$ref":"#/definitions/Tag"}},"status":{"type":"string","description":"pet status in the store","enum":["available","pending","sold"]}},"xml":{"name":"Pet"}},"ApiResponse":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"type":{"type":"string"},"message":{"type":"string"}}}},"externalDocs":{"description":"Find out more about Swagger","url":"http://swagger.io"}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/pom.xml b/tooling/swagger-rest-dsl-generator/pom.xml
new file mode 100644
index 0000000..85168a2
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/pom.xml
@@ -0,0 +1,70 @@
+<?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.
+-->
+<project xmlns="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/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>tooling</artifactId>
+    <version>2.19.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>swagger-rest-dsl-generator</artifactId>
+  <name>Camel :: Tooling :: Swagger REST DSL Generator</name>
+  <description>Generator of REST DSL route definitions from Swagger (OpenAPI) specification</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.squareup</groupId>
+      <artifactId>javapoet</artifactId>
+      <version>${javapoet-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>io.swagger</groupId>
+      <artifactId>swagger-parser</artifactId>
+      <version>${swagger-java-parser-version}</version>
+    </dependency>
+
+    <!-- test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <version>${assertj-version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/AppendableGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/AppendableGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/AppendableGenerator.java
new file mode 100644
index 0000000..09cbf09
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/AppendableGenerator.java
@@ -0,0 +1,38 @@
+/**
+ * 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.generator.swagger;
+
+import java.io.IOException;
+
+import com.squareup.javapoet.JavaFile;
+
+import io.swagger.models.Swagger;
+
+final class AppendableGenerator extends RestDslSourceCodeGenerator<Appendable> {
+
+    AppendableGenerator(final Swagger swagger) {
+        super(swagger);
+    }
+
+    @Override
+    public void generate(final Appendable destination) throws IOException {
+        final JavaFile javaFile = generateSourceCode();
+
+        javaFile.writeTo(destination);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/CodeEmitter.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/CodeEmitter.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/CodeEmitter.java
new file mode 100644
index 0000000..e914367
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/CodeEmitter.java
@@ -0,0 +1,25 @@
+/**
+ * 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.generator.swagger;
+
+interface CodeEmitter<T> {
+
+    CodeEmitter<T> emit(String method, Object... args);
+
+    T result();
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/FilerGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/FilerGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/FilerGenerator.java
new file mode 100644
index 0000000..b1e56db
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/FilerGenerator.java
@@ -0,0 +1,40 @@
+/**
+ * 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.generator.swagger;
+
+import java.io.IOException;
+
+import javax.annotation.processing.Filer;
+
+import com.squareup.javapoet.JavaFile;
+
+import io.swagger.models.Swagger;
+
+final class FilerGenerator extends RestDslSourceCodeGenerator<Filer> {
+
+    FilerGenerator(final Swagger swagger) {
+        super(swagger);
+    }
+
+    @Override
+    public void generate(final Filer destination) throws IOException {
+        final JavaFile javaFile = generateSourceCode();
+
+        javaFile.writeTo(destination);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitter.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitter.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitter.java
new file mode 100644
index 0000000..a9dd879
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitter.java
@@ -0,0 +1,166 @@
+/**
+ * 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.generator.swagger;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.List;
+import java.util.StringJoiner;
+import java.util.stream.Collectors;
+
+import com.squareup.javapoet.MethodSpec;
+
+import static org.apache.commons.lang3.ClassUtils.isPrimitiveOrWrapper;
+
+class MethodBodySourceCodeEmitter implements CodeEmitter<MethodSpec> {
+
+    private final MethodSpec.Builder builder;
+
+    private boolean first = true;
+
+    private final Deque<Integer> indentIntentStack = new ArrayDeque<>();
+
+    private final Deque<Integer> indentStack = new ArrayDeque<>();
+
+    MethodBodySourceCodeEmitter(final MethodSpec.Builder builder) {
+        this.builder = builder;
+        indentStack.push(0);
+    }
+
+    @Override
+    public CodeEmitter<MethodSpec> emit(final String method, final Object... args) {
+        final boolean hasArgs = args != null && args.length > 0;
+
+        final int indent = indentLevelOf(method);
+
+        if (!first) {
+            builder.addCode("\n");
+        }
+
+        builder.addCode(String.join("", Collections.nCopies(indentStack.peek(), "$<")));
+        builder.addCode(String.join("", Collections.nCopies(indent, "$>")));
+
+        if (!first) {
+            builder.addCode(".");
+        }
+
+        indentStack.push(indent);
+
+        if (hasArgs) {
+            builder.addCode("$L(" + invocationLiteralsFor(args) + ")", extend(method, argumentsFor(args)));
+        } else {
+            builder.addCode("$L()", method);
+        }
+
+        first = false;
+
+        return this;
+    }
+
+    @Override
+    public MethodSpec result() {
+        builder.addCode(String.join("", Collections.nCopies(indentStack.peek(), "$<")));
+        builder.addCode(";\n");
+        return builder.build();
+    }
+
+    Object[] argumentsFor(final Object[] args) {
+        final List<Object> arguments = new ArrayList<>(args.length);
+
+        for (final Object arg : args) {
+            if (isPrimitiveOrWrapper(arg.getClass())) {
+                arguments.add(arg);
+            } else if (arg instanceof String) {
+                arguments.add(arg);
+            } else if (arg instanceof Enum) {
+                arguments.add(arg.getClass());
+                arguments.add(arg);
+            } else if (arg instanceof String[]) {
+                arguments.add(Arrays.stream((String[]) arg).collect(Collectors.joining(",")));
+            }
+        }
+
+        return arguments.toArray(new Object[arguments.size()]);
+    }
+
+    Object[] extend(final Object first, final Object... others) {
+        if (others == null || others.length == 0) {
+            return new Object[] {first};
+        }
+
+        final Object[] ret = new Object[1 + others.length];
+
+        ret[0] = first;
+        System.arraycopy(others, 0, ret, 1, others.length);
+
+        return ret;
+    }
+
+    int indentLevelOf(final String method) {
+        switch (method) {
+        case "rest":
+            return 0;
+        case "post":
+        case "get":
+        case "put":
+        case "patch":
+        case "delete":
+        case "head":
+        case "options":
+            return 1;
+        case "param":
+            indentIntentStack.push(3);
+            return 2;
+        case "endParam":
+            indentIntentStack.pop();
+            return 2;
+        case "route":
+            indentIntentStack.push(3);
+            return 2;
+        case "endRest":
+            indentIntentStack.pop();
+            return 2;
+        default:
+            if (indentIntentStack.isEmpty()) {
+                return 2;
+            }
+            return indentIntentStack.peek();
+        }
+    }
+
+    String invocationLiteralsFor(final Object[] args) {
+        final StringJoiner literals = new StringJoiner(",");
+
+        for (final Object arg : args) {
+            if (isPrimitiveOrWrapper(arg.getClass())) {
+                literals.add("$L");
+            } else if (arg instanceof String) {
+                literals.add("$S");
+            } else if (arg instanceof Enum) {
+                literals.add("$T.$L");
+            } else if (arg instanceof String[]) {
+                literals.add("$S");
+            }
+        }
+
+        return literals.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/OperationVisitor.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/OperationVisitor.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/OperationVisitor.java
new file mode 100644
index 0000000..37390d1
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/OperationVisitor.java
@@ -0,0 +1,122 @@
+/**
+ * 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.generator.swagger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+
+import io.swagger.models.HttpMethod;
+import io.swagger.models.Operation;
+import io.swagger.models.parameters.AbstractSerializableParameter;
+import io.swagger.models.parameters.Parameter;
+import io.swagger.models.properties.Property;
+
+import org.apache.camel.model.rest.CollectionFormat;
+import org.apache.camel.model.rest.RestParamType;
+import org.apache.camel.util.ObjectHelper;
+
+class OperationVisitor<T> {
+
+    private final Function<Operation, String> directRouteGenerator;
+
+    private final CodeEmitter<T> emitter;
+
+    private final String path;
+
+    OperationVisitor(final CodeEmitter<T> emitter, final String path,
+        final Function<Operation, String> directRouteGenerator) {
+        this.emitter = emitter;
+        this.path = path;
+        this.directRouteGenerator = directRouteGenerator;
+    }
+
+    List<String> asStringList(final List<?> values) {
+        if (values == null || values.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        final List<String> stringList = new ArrayList<>();
+        values.forEach(v -> stringList.add(String.valueOf(v)));
+
+        return stringList;
+    }
+
+    CodeEmitter<T> emit(final Parameter parameter) {
+        emitter.emit("param");
+        emit("name", parameter.getName());
+        final String parameterType = parameter.getIn();
+        if (ObjectHelper.isNotEmpty(parameterType)) {
+            emit("type", RestParamType.valueOf(parameterType));
+        }
+        if (parameter instanceof AbstractSerializableParameter) {
+            final AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
+
+            final String dataType = serializableParameter.getType();
+            emit("dataType", dataType);
+            emit("allowableValues", asStringList(serializableParameter.getEnumValue()));
+            final String collectionFormat = serializableParameter.getCollectionFormat();
+            if (ObjectHelper.isNotEmpty(collectionFormat)) {
+                emit("collectionFormat", CollectionFormat.valueOf(collectionFormat));
+            }
+            emit("defaultValue", serializableParameter.getDefault());
+
+            final Property items = serializableParameter.getItems();
+            if ("array".equals(dataType) && items != null) {
+                emit("arrayType", items.getType());
+            }
+        }
+        emit("required", parameter.getRequired());
+        emit("description", parameter.getDescription());
+        emitter.emit("endParam");
+
+        return emitter;
+    }
+
+    CodeEmitter<T> emit(final String method, final List<String> values) {
+        if (values == null || values.isEmpty()) {
+            return emitter;
+        }
+
+        return emitter.emit(method, new Object[] {values.toArray(new String[values.size()])});
+    }
+
+    CodeEmitter<T> emit(final String method, final Object value) {
+        if (ObjectHelper.isEmpty(value)) {
+            return emitter;
+        }
+
+        return emitter.emit(method, value);
+    }
+
+    void visit(final HttpMethod method, final Operation operation) {
+        final String methodName = method.name().toLowerCase();
+        emitter.emit(methodName, path);
+
+        emit("id", operation.getOperationId());
+        emit("description", operation.getDescription());
+        emit("consumes", operation.getConsumes());
+        emit("produces", operation.getProduces());
+
+        operation.getParameters().forEach(parameter -> {
+            emit(parameter);
+        });
+
+        emitter.emit("to", directRouteGenerator.apply(operation));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathGenerator.java
new file mode 100644
index 0000000..9886de7
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathGenerator.java
@@ -0,0 +1,39 @@
+/**
+ * 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.generator.swagger;
+
+import java.io.IOException;
+import java.nio.file.Path;
+
+import com.squareup.javapoet.JavaFile;
+
+import io.swagger.models.Swagger;
+
+final class PathGenerator extends RestDslSourceCodeGenerator<Path> {
+
+    PathGenerator(final Swagger swagger) {
+        super(swagger);
+    }
+
+    @Override
+    public void generate(final Path destination) throws IOException {
+        final JavaFile javaFile = generateSourceCode();
+
+        javaFile.writeTo(destination);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathVisitor.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathVisitor.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathVisitor.java
new file mode 100644
index 0000000..1745189
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/PathVisitor.java
@@ -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.generator.swagger;
+
+import java.util.function.Function;
+
+import io.swagger.models.Operation;
+import io.swagger.models.Path;
+
+class PathVisitor<T> {
+
+    private final Function<Operation, String> directRouteGenerator;
+
+    private final CodeEmitter<T> emitter;
+
+    PathVisitor(final CodeEmitter<T> emitter, final Function<Operation, String> directRouteGenerator) {
+        this.emitter = emitter;
+        this.directRouteGenerator = directRouteGenerator;
+
+        emitter.emit("rest");
+    }
+
+    void visit(final String path, final Path definition) {
+        final OperationVisitor<T> restDslOperation = new OperationVisitor<>(emitter, path, directRouteGenerator);
+
+        definition.getOperationMap().forEach(restDslOperation::visit);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
new file mode 100644
index 0000000..4cb93a6
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
@@ -0,0 +1,99 @@
+/**
+ * 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.generator.swagger;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.rest.RestsDefinition;
+
+class RestDefinitionEmitter implements CodeEmitter<RestsDefinition> {
+
+    private final RestsDefinition definition;
+
+    private Object variable;
+
+    RestDefinitionEmitter(final CamelContext context) {
+        definition = new RestsDefinition();
+        variable = definition;
+    }
+
+    @Override
+    public CodeEmitter<RestsDefinition> emit(final String method, final Object... args) {
+        try {
+            final Class<? extends Object> type = variable.getClass();
+
+            final Object[] arguments = argumentsFor(args);
+
+            final Method declaredMethod = type.getMethod(method, parameterTypesOf(arguments));
+
+            variable = declaredMethod.invoke(variable, arguments);
+        } catch (final Throwable e) {
+            if (e instanceof RuntimeException) {
+                throw (RuntimeException) e;
+            } else {
+                throw new IllegalStateException(e);
+            }
+        }
+
+        return this;
+    }
+
+    @Override
+    public RestsDefinition result() {
+        return definition;
+    }
+
+    Object[] argumentsFor(final Object[] args) {
+        final List<Object> arguments = new ArrayList<>(args.length);
+
+        for (final Object arg : args) {
+            if (arg instanceof String[]) {
+                arguments.add(Arrays.stream((String[]) arg).collect(Collectors.joining(",")));
+            } else {
+                arguments.add(arg);
+            }
+        }
+
+        return arguments.toArray(new Object[arguments.size()]);
+    }
+
+    Class<?>[] parameterTypesOf(final Object[] args) {
+        final Class<?>[] parameterTypes = new Class<?>[args.length];
+
+        for (int i = 0; i < args.length; i++) {
+            parameterTypes[i] = args[i].getClass();
+        }
+
+        return parameterTypes;
+    }
+
+    Class<?>[] typesOf(final Object[] args) {
+        final Class<?>[] types = new Class<?>[args.length];
+
+        for (int i = 0; i < types.length; i++) {
+            types[i] = args[i].getClass();
+        }
+
+        return types;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslDefinitionGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslDefinitionGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslDefinitionGenerator.java
new file mode 100644
index 0000000..c8d74b3
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslDefinitionGenerator.java
@@ -0,0 +1,40 @@
+/**
+ * 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.generator.swagger;
+
+import io.swagger.models.Swagger;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.rest.RestsDefinition;
+
+class RestDslDefinitionGenerator extends RestDslGenerator<RestDslDefinitionGenerator> {
+
+    RestDslDefinitionGenerator(final Swagger swagger) {
+        super(swagger);
+    }
+
+    public RestsDefinition generate(final CamelContext context) {
+        final RestDefinitionEmitter emitter = new RestDefinitionEmitter(context);
+
+        final PathVisitor<RestsDefinition> restDslStatement = new PathVisitor<>(emitter, directRouteGenerator());
+
+        swagger.getPaths().forEach(restDslStatement::visit);
+
+        return emitter.result();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java
new file mode 100644
index 0000000..e47fddf
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslGenerator.java
@@ -0,0 +1,86 @@
+/**
+ * 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.generator.swagger;
+
+import java.nio.file.Path;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+
+import javax.annotation.processing.Filer;
+
+import io.swagger.models.Operation;
+import io.swagger.models.Swagger;
+
+import org.apache.camel.model.rest.RestsDefinition;
+
+import static org.apache.camel.util.ObjectHelper.notNull;
+
+/**
+ * Source code and {@link RestsDefinition} generator that generates Camel REST
+ * DSL implementations from Swagger (OpenAPI) specifications.
+ */
+public abstract class RestDslGenerator<G> {
+
+    final Swagger swagger;
+
+    private final AtomicInteger directRouteCount = new AtomicInteger(0);
+
+    private Function<Operation, String> directRouteGenerator = this::generateDirectRouteName;
+
+    RestDslGenerator(final Swagger swagger) {
+        this.swagger = notNull(swagger, "swagger");
+    }
+
+    public G withDirectRouteGenerator(final Function<Operation, String> directRouteGenerator) {
+        notNull(directRouteGenerator, "directRouteGenerator");
+        this.directRouteGenerator = directRouteGenerator;
+
+        @SuppressWarnings("unchecked")
+        final G that = (G) this;
+
+        return that;
+    }
+
+    Function<Operation, String> directRouteGenerator() {
+        return directRouteGenerator;
+    }
+
+    String generateDirectName() {
+        return "rest" + directRouteCount.incrementAndGet();
+    }
+
+    String generateDirectRouteName(final Operation operation) {
+        return "direct:" + Optional.ofNullable(operation.getOperationId()).orElseGet(this::generateDirectName);
+    }
+
+    public static RestDslSourceCodeGenerator<Appendable> toAppendable(final Swagger swagger) {
+        return new AppendableGenerator(swagger);
+    }
+
+    public static RestDslDefinitionGenerator toDefinition(final Swagger swagger) {
+        return new RestDslDefinitionGenerator(swagger);
+    }
+
+    public static RestDslSourceCodeGenerator<Filer> toFiler(final Swagger swagger) {
+        return new FilerGenerator(swagger);
+    }
+
+    public static RestDslSourceCodeGenerator<Path> toPath(final Swagger swagger) {
+        return new PathGenerator(swagger);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java
new file mode 100644
index 0000000..c2b9ce1
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslSourceCodeGenerator.java
@@ -0,0 +1,137 @@
+/**
+ * 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.generator.swagger;
+
+import java.io.IOException;
+import java.util.function.Function;
+import java.util.stream.Collector;
+
+import javax.lang.model.element.Modifier;
+
+import com.squareup.javapoet.JavaFile;
+import com.squareup.javapoet.MethodSpec;
+import com.squareup.javapoet.TypeSpec;
+
+import io.swagger.models.Info;
+import io.swagger.models.Swagger;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.ObjectHelper;
+
+import static org.apache.camel.util.StringHelper.notEmpty;
+
+public abstract class RestDslSourceCodeGenerator<T> extends RestDslGenerator<RestDslSourceCodeGenerator<T>> {
+    private static final String DEFAULT_CLASS_NAME = "RestDslRoute";
+
+    private static final String DEFAULT_INDENT = "    ";
+
+    private static final String DEFAULT_PACKAGE_NAME = "rest.dsl.generated";
+
+    private Function<Swagger, String> classNameGenerator = RestDslSourceCodeGenerator::generateClassName;
+
+    private String indent = DEFAULT_INDENT;
+
+    private Function<Swagger, String> packageNameGenerator = RestDslSourceCodeGenerator::generatePackageName;
+
+    RestDslSourceCodeGenerator(final Swagger swagger) {
+        super(swagger);
+    }
+
+    public abstract void generate(T destination) throws IOException;
+
+    public RestDslSourceCodeGenerator<T> withClassName(final String className) {
+        notEmpty(className, "className");
+        this.classNameGenerator = (s) -> className;
+
+        return this;
+    }
+
+    public RestDslSourceCodeGenerator<T> withIndent(final String indent) {
+        this.indent = ObjectHelper.notNull(indent, "indent");
+
+        return this;
+    }
+
+    public RestDslSourceCodeGenerator<T> withPackageName(final String packageName) {
+        notEmpty(packageName, "packageName");
+        this.packageNameGenerator = (s) -> packageName;
+
+        return this;
+    }
+
+    MethodSpec generateConfigureMethod(final Swagger swagger) {
+        final MethodSpec.Builder configure = MethodSpec.methodBuilder("configure").addModifiers(Modifier.PUBLIC)
+            .returns(void.class).addJavadoc("Defines Apache Camel routes using REST DSL fluent API.\n");
+
+        final MethodBodySourceCodeEmitter emitter = new MethodBodySourceCodeEmitter(configure);
+
+        final PathVisitor<MethodSpec> restDslStatement = new PathVisitor<>(emitter, directRouteGenerator());
+        swagger.getPaths().forEach(restDslStatement::visit);
+
+        return emitter.result();
+    }
+
+    JavaFile generateSourceCode() {
+        final MethodSpec methodSpec = generateConfigureMethod(swagger);
+
+        final String classNameToUse = classNameGenerator.apply(swagger);
+
+        final TypeSpec generatedRouteBulder = TypeSpec.classBuilder(classNameToUse).superclass(RouteBuilder.class)
+            .addModifiers(Modifier.PUBLIC, Modifier.FINAL).addMethod(methodSpec)
+            .addJavadoc("Generated from Swagger specification by Camel REST DSL generator.\n").build();
+
+        final String packageNameToUse = packageNameGenerator.apply(swagger);
+
+        return JavaFile.builder(packageNameToUse, generatedRouteBulder).indent(indent).build();
+    }
+
+    static String generateClassName(final Swagger swagger) {
+        final Info info = swagger.getInfo();
+        if (info == null) {
+            return DEFAULT_CLASS_NAME;
+        }
+
+        final String title = info.getTitle();
+        if (title == null) {
+            return DEFAULT_CLASS_NAME;
+        }
+
+        return title.chars().filter(Character::isJavaIdentifierPart).boxed().collect(Collector.of(StringBuilder::new,
+            StringBuilder::appendCodePoint, StringBuilder::append, StringBuilder::toString));
+    }
+
+    static String generatePackageName(final Swagger swagger) {
+        final String host = swagger.getHost();
+
+        if (ObjectHelper.isNotEmpty(host)) {
+            final StringBuilder packageName = new StringBuilder();
+
+            final String[] parts = host.split("\\.");
+
+            for (int i = parts.length - 1; i >= 0; i--) {
+                packageName.append(parts[i]);
+                if (i != 0) {
+                    packageName.append('.');
+                }
+            }
+
+            return packageName.toString();
+        }
+
+        return DEFAULT_PACKAGE_NAME;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitterTest.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitterTest.java b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitterTest.java
new file mode 100644
index 0000000..9200cd0
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/MethodBodySourceCodeEmitterTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.generator.swagger;
+
+import com.squareup.javapoet.MethodSpec;
+import com.squareup.javapoet.MethodSpec.Builder;
+
+import org.apache.camel.model.rest.RestParamType;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MethodBodySourceCodeEmitterTest {
+
+    @Test
+    public void shouldGenerateSourceCode() {
+        final Builder method = MethodSpec.methodBuilder("configure");
+
+        final MethodBodySourceCodeEmitter emitter = new MethodBodySourceCodeEmitter(method);
+
+        emitter.emit("rest");
+        emitter.emit("put", "/pet");
+        emitter.emit("consumes", new Object[] {new String[] {"application/json", "application/xml"}});
+        emitter.emit("produces", new Object[] {new String[] {"application/xml", "application/json"}});
+        emitter.emit("param");
+        emitter.emit("name", "body");
+        emitter.emit("type", RestParamType.body);
+        emitter.emit("required", true);
+        emitter.emit("endParam");
+
+        assertThat(emitter.result().toString()).isEqualTo("void configure() {\n"//
+            + "  rest()\n"//
+            + "    .put(\"/pet\")\n"//
+            + "      .consumes(\"application/json,application/xml\")\n"//
+            + "      .produces(\"application/xml,application/json\")\n"//
+            + "      .param()\n"//
+            + "        .name(\"body\")\n"//
+            + "        .type(org.apache.camel.model.rest.RestParamType.body)\n"//
+            + "        .required(true)\n"//
+            + "      .endParam();\n"//
+            + "}\n");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDefinitionEmitterTest.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDefinitionEmitterTest.java b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDefinitionEmitterTest.java
new file mode 100644
index 0000000..92674f5
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDefinitionEmitterTest.java
@@ -0,0 +1,70 @@
+/**
+ * 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.generator.swagger;
+
+import java.util.List;
+
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.rest.RestOperationParamDefinition;
+import org.apache.camel.model.rest.RestParamType;
+import org.apache.camel.model.rest.RestsDefinition;
+import org.apache.camel.model.rest.VerbDefinition;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RestDefinitionEmitterTest {
+    @Test
+    public void shouldGenerateObjects() {
+        final DefaultCamelContext context = new DefaultCamelContext();
+
+        final RestDefinitionEmitter emitter = new RestDefinitionEmitter(context);
+
+        emitter.emit("rest");
+        emitter.emit("put", "/pet");
+        emitter.emit("consumes", new Object[] {new String[] {"application/json", "application/xml"}});
+        emitter.emit("produces", new Object[] {new String[] {"application/xml", "application/json"}});
+        emitter.emit("param");
+        emitter.emit("name", "body");
+        emitter.emit("type", RestParamType.body);
+        emitter.emit("required", true);
+        emitter.emit("endParam");
+
+        final RestsDefinition result = emitter.result();
+        final List<RestDefinition> rests = result.getRests();
+        assertThat(rests).hasSize(1);
+
+        final RestDefinition rest = rests.get(0);
+        final List<VerbDefinition> verbs = rest.getVerbs();
+        assertThat(verbs).hasSize(1);
+
+        final VerbDefinition definition = verbs.get(0);
+        assertThat(definition.asVerb()).isEqualTo("put");
+        assertThat(definition.getUri()).isEqualTo("/pet");
+        assertThat(definition.getConsumes()).isEqualTo("application/json,application/xml");
+        assertThat(definition.getProduces()).isEqualTo("application/xml,application/json");
+
+        final List<RestOperationParamDefinition> params = definition.getParams();
+        assertThat(params).hasSize(1);
+
+        final RestOperationParamDefinition param = params.get(0);
+        assertThat(param.getName()).isEqualTo("body");
+        assertThat(param.getType()).isEqualTo(RestParamType.body);
+        assertThat(param.getRequired()).isEqualTo(true);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDslGeneratorTest.java
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDslGeneratorTest.java b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDslGeneratorTest.java
new file mode 100644
index 0000000..113fbef
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/test/java/org/apache/camel/generator/swagger/RestDslGeneratorTest.java
@@ -0,0 +1,73 @@
+/**
+ * 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.generator.swagger;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import io.swagger.models.Swagger;
+import io.swagger.parser.SwaggerParser;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.model.rest.RestsDefinition;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RestDslGeneratorTest {
+
+    final Swagger swagger = new SwaggerParser().read("petstore.json");
+
+    @Test
+    public void shouldCreateDefinitions() {
+        final CamelContext context = new DefaultCamelContext();
+
+        final RestsDefinition definition = RestDslGenerator.toDefinition(swagger).generate(context);
+
+        assertThat(definition).isNotNull();
+    }
+
+    @Test
+    public void shouldGenerateSourceCodeWithDefaults() throws IOException, URISyntaxException {
+        final StringBuilder code = new StringBuilder();
+
+        RestDslGenerator.toAppendable(swagger).generate(code);
+
+        final URI file = RestDslGeneratorTest.class.getResource("/SwaggerPetstore.txt").toURI();
+        final String expectedContent = new String(Files.readAllBytes(Paths.get(file)), StandardCharsets.UTF_8);
+
+        assertThat(code.toString()).isEqualTo(expectedContent);
+    }
+
+    @Test
+    public void shouldGenerateSourceCodeWithOptions() throws IOException, URISyntaxException {
+        final StringBuilder code = new StringBuilder();
+
+        RestDslGenerator.toAppendable(swagger).withClassName("MyRestRoute").withPackageName("com.example")
+            .withIndent("\t").withDirectRouteGenerator(o -> "direct:rest-" + o.getOperationId()).generate(code);
+
+        final URI file = RestDslGeneratorTest.class.getResource("/MyRestRoute.txt").toURI();
+        final String expectedContent = new String(Files.readAllBytes(Paths.get(file)), StandardCharsets.UTF_8);
+
+        assertThat(code.toString()).isEqualTo(expectedContent);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/29d3f1c1/tooling/swagger-rest-dsl-generator/src/test/resources/MyRestRoute.txt
----------------------------------------------------------------------
diff --git a/tooling/swagger-rest-dsl-generator/src/test/resources/MyRestRoute.txt b/tooling/swagger-rest-dsl-generator/src/test/resources/MyRestRoute.txt
new file mode 100644
index 0000000..4b19f69
--- /dev/null
+++ b/tooling/swagger-rest-dsl-generator/src/test/resources/MyRestRoute.txt
@@ -0,0 +1,281 @@
+package com.example;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.rest.CollectionFormat;
+import org.apache.camel.model.rest.RestParamType;
+
+/**
+ * Generated from Swagger specification by Camel REST DSL generator.
+ */
+public final class MyRestRoute extends RouteBuilder {
+	/**
+	 * Defines Apache Camel routes using REST DSL fluent API.
+	 */
+	public void configure() {
+		rest()
+			.put("/pet")
+				.id("updatePet")
+				.consumes("application/json,application/xml")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("Pet object that needs to be added to the store")
+				.endParam()
+				.to("direct:rest-updatePet")
+			.post("/pet")
+				.id("addPet")
+				.consumes("application/json,application/xml")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("Pet object that needs to be added to the store")
+				.endParam()
+				.to("direct:rest-addPet")
+			.get("/pet/findByStatus")
+				.id("findPetsByStatus")
+				.description("Multiple status values can be provided with comma separated strings")
+				.produces("application/xml,application/json")
+				.param()
+					.name("status")
+					.type(RestParamType.query)
+					.dataType("array")
+					.collectionFormat(CollectionFormat.multi)
+					.arrayType("string")
+					.required(true)
+					.description("Status values that need to be considered for filter")
+				.endParam()
+				.to("direct:rest-findPetsByStatus")
+			.get("/pet/findByTags")
+				.id("findPetsByTags")
+				.description("Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.")
+				.produces("application/xml,application/json")
+				.param()
+					.name("tags")
+					.type(RestParamType.query)
+					.dataType("array")
+					.collectionFormat(CollectionFormat.multi)
+					.arrayType("string")
+					.required(true)
+					.description("Tags to filter by")
+				.endParam()
+				.to("direct:rest-findPetsByTags")
+			.get("/pet/{petId}")
+				.id("getPetById")
+				.description("Returns a single pet")
+				.produces("application/xml,application/json")
+				.param()
+					.name("petId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("ID of pet to return")
+				.endParam()
+				.to("direct:rest-getPetById")
+			.post("/pet/{petId}")
+				.id("updatePetWithForm")
+				.consumes("application/x-www-form-urlencoded")
+				.produces("application/xml,application/json")
+				.param()
+					.name("petId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("ID of pet that needs to be updated")
+				.endParam()
+				.param()
+					.name("name")
+					.type(RestParamType.formData)
+					.dataType("string")
+					.required(false)
+					.description("Updated name of the pet")
+				.endParam()
+				.param()
+					.name("status")
+					.type(RestParamType.formData)
+					.dataType("string")
+					.required(false)
+					.description("Updated status of the pet")
+				.endParam()
+				.to("direct:rest-updatePetWithForm")
+			.delete("/pet/{petId}")
+				.id("deletePet")
+				.produces("application/xml,application/json")
+				.param()
+					.name("api_key")
+					.type(RestParamType.header)
+					.dataType("string")
+					.required(false)
+				.endParam()
+				.param()
+					.name("petId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("Pet id to delete")
+				.endParam()
+				.to("direct:rest-deletePet")
+			.post("/pet/{petId}/uploadImage")
+				.id("uploadFile")
+				.consumes("multipart/form-data")
+				.produces("application/json")
+				.param()
+					.name("petId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("ID of pet to update")
+				.endParam()
+				.param()
+					.name("additionalMetadata")
+					.type(RestParamType.formData)
+					.dataType("string")
+					.required(false)
+					.description("Additional data to pass to server")
+				.endParam()
+				.param()
+					.name("file")
+					.type(RestParamType.formData)
+					.dataType("file")
+					.required(false)
+					.description("file to upload")
+				.endParam()
+				.to("direct:rest-uploadFile")
+			.get("/store/inventory")
+				.id("getInventory")
+				.description("Returns a map of status codes to quantities")
+				.produces("application/json")
+				.to("direct:rest-getInventory")
+			.post("/store/order")
+				.id("placeOrder")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("order placed for purchasing the pet")
+				.endParam()
+				.to("direct:rest-placeOrder")
+			.get("/store/order/{orderId}")
+				.id("getOrderById")
+				.description("For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions")
+				.produces("application/xml,application/json")
+				.param()
+					.name("orderId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("ID of pet that needs to be fetched")
+				.endParam()
+				.to("direct:rest-getOrderById")
+			.delete("/store/order/{orderId}")
+				.id("deleteOrder")
+				.description("For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors")
+				.produces("application/xml,application/json")
+				.param()
+					.name("orderId")
+					.type(RestParamType.path)
+					.dataType("integer")
+					.required(true)
+					.description("ID of the order that needs to be deleted")
+				.endParam()
+				.to("direct:rest-deleteOrder")
+			.post("/user")
+				.id("createUser")
+				.description("This can only be done by the logged in user.")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("Created user object")
+				.endParam()
+				.to("direct:rest-createUser")
+			.post("/user/createWithArray")
+				.id("createUsersWithArrayInput")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("List of user object")
+				.endParam()
+				.to("direct:rest-createUsersWithArrayInput")
+			.post("/user/createWithList")
+				.id("createUsersWithListInput")
+				.produces("application/xml,application/json")
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("List of user object")
+				.endParam()
+				.to("direct:rest-createUsersWithListInput")
+			.get("/user/login")
+				.id("loginUser")
+				.produces("application/xml,application/json")
+				.param()
+					.name("username")
+					.type(RestParamType.query)
+					.dataType("string")
+					.required(true)
+					.description("The user name for login")
+				.endParam()
+				.param()
+					.name("password")
+					.type(RestParamType.query)
+					.dataType("string")
+					.required(true)
+					.description("The password for login in clear text")
+				.endParam()
+				.to("direct:rest-loginUser")
+			.get("/user/logout")
+				.id("logoutUser")
+				.produces("application/xml,application/json")
+				.to("direct:rest-logoutUser")
+			.get("/user/{username}")
+				.id("getUserByName")
+				.produces("application/xml,application/json")
+				.param()
+					.name("username")
+					.type(RestParamType.path)
+					.dataType("string")
+					.required(true)
+					.description("The name that needs to be fetched. Use user1 for testing. ")
+				.endParam()
+				.to("direct:rest-getUserByName")
+			.put("/user/{username}")
+				.id("updateUser")
+				.description("This can only be done by the logged in user.")
+				.produces("application/xml,application/json")
+				.param()
+					.name("username")
+					.type(RestParamType.path)
+					.dataType("string")
+					.required(true)
+					.description("name that need to be updated")
+				.endParam()
+				.param()
+					.name("body")
+					.type(RestParamType.body)
+					.required(true)
+					.description("Updated user object")
+				.endParam()
+				.to("direct:rest-updateUser")
+			.delete("/user/{username}")
+				.id("deleteUser")
+				.description("This can only be done by the logged in user.")
+				.produces("application/xml,application/json")
+				.param()
+					.name("username")
+					.type(RestParamType.path)
+					.dataType("string")
+					.required(true)
+					.description("The name that needs to be deleted")
+				.endParam()
+				.to("direct:rest-deleteUser");
+	}
+}