camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] 03/05: CAMEL-12841: camel-restdsl-swagger:generate - Add restConfiguration with common defaults
Date Sun, 30 Sep 2018 15:23:49 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 42a877d10541a1e02f099d7f3c7bb876fb8776c9
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Sun Sep 30 09:34:45 2018 +0200

    CAMEL-12841: camel-restdsl-swagger:generate - Add restConfiguration with common defaults
---
 .../maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/pom.xml | 5 +++++
 .../camel-restdsl-swagger-plugin/src/it/simple-xml-dto/verify.groovy | 4 ++++
 .../apache/camel/maven/generator/swagger/AbstractGenerateMojo.java   | 3 ++-
 .../java/org/apache/camel/maven/generator/swagger/GenerateMojo.java  | 1 +
 .../org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java    | 1 +
 .../java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java | 2 +-
 6 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/pom.xml b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/pom.xml
index 9b4b5a3..a564b6a 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/pom.xml
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/pom.xml
@@ -45,6 +45,11 @@
       <version>@project.version@</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty9</artifactId>
+      <version>@project.version@</version>
+    </dependency>
+    <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>
       <version>2.8.5</version>
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/verify.groovy
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/verify.groovy
index 0efda6a..2144ea7 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/verify.groovy
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-xml-dto/verify.groovy
@@ -19,6 +19,10 @@ def File restdsl = new File(basedir, "target/generated-sources/restdsl-swagger/c
 
 assert restdsl.exists()
 
+def String data = restdsl.text
+
+assert data.contains('<restConfiguration component="jetty"/>')
+
 def File restdto = new File(basedir, "target/generated-sources/swagger/src/main/java/io/swagger/client/model/Order.java")
 
 assert restdto.exists()
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
index cb3384d..73e74ca 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
@@ -48,7 +48,8 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.version;
 
 abstract class AbstractGenerateMojo extends AbstractMojo {
 
-    public static final String[] DEFAULT_REST_CONSUMER_COMPONENTS = new String[]{"coap",
"netty-http", "netty4-http", "jetty", "restlet", "servlet", "spark-java", "undertow"};
+    // this list should be in priority order
+    public static final String[] DEFAULT_REST_CONSUMER_COMPONENTS = new String[]{"servlet",
"undertow", "jetty", "restlet", "netty-http", "netty4-http", "spark-java", "coap"};
 
     @Parameter
     String destinationGenerator;
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
index f0ffcec..bdafbbd 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
@@ -89,6 +89,7 @@ public class GenerateMojo extends AbstractGenerateMojo {
 
         String comp = detectRestComponentFromClasspath();
         if (comp != null) {
+            getLog().info("Detected Camel Rest component: " + comp);
             generator.withRestComponent(comp);
         }
 
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
index eca0d0e..f01d81d 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
@@ -79,6 +79,7 @@ public class GenerateXmlMojo extends AbstractGenerateMojo {
 
         String comp = detectRestComponentFromClasspath();
         if (comp != null) {
+            getLog().info("Detected Camel Rest component: " + comp);
             generator.withRestComponent(comp);
         }
 
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java
b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java
index 50d6188..d57d340 100644
--- a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDslXmlGenerator.java
@@ -52,7 +52,7 @@ public class RestDslXmlGenerator extends RestDslGenerator<RestDslXmlGenerator>
{
 
         if (restComponent != null) {
             String extra = "<restConfiguration component=\"" + restComponent + "\"/>";
-            xml = xml.replaceFirst("<rest>", extra + "\n<rest>");
+            xml = xml.replaceFirst("<rest>", extra + "\n    <rest>");
         }
 
         return xml;


Mime
View raw message