camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] 04/04: CAMEL-12828: camel-restdsl-swagger:generate - Add option to generate dto objects
Date Thu, 27 Sep 2018 10:35:32 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 8a5e7ee1d7a061670331da8c8fc7207ce06761bf
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Thu Sep 27 12:04:12 2018 +0200

    CAMEL-12828: camel-restdsl-swagger:generate - Add option to generate dto objects
---
 .../src/it/simple-dto/pom.xml                      |  1 +
 .../main/docs/camel-restdsl-swagger-plugin.adoc    | 48 ++++++++++++++++++++++
 .../generator/swagger/AbstractGenerateMojo.java    | 24 +++++++++++
 3 files changed, 73 insertions(+)

diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-dto/pom.xml b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-dto/pom.xml
index 005ad2a..7ebd095 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-dto/pom.xml
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/it/simple-dto/pom.xml
@@ -70,6 +70,7 @@
             </goals>
             <configuration>
               <modelPackage>com.foo</modelPackage>
+              <modelWithXml>false</modelWithXml>
             </configuration>
           </execution>
         </executions>
diff --git a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
index a999532..e7b5c0d 100644
--- a/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
+++ b/tooling/maven/camel-restdsl-swagger-plugin/src/main/docs/camel-restdsl-swagger-plugin.adoc
@@ -46,6 +46,26 @@ Works as `generate` goal but also generates DTO model classes by automatic
execu
 the swagger-codegen-maven-plugin to generate java source code of the DTO model classes
 from the swagger specification.
 
+This plugin has been scoped and limited to only support a good effort set of defaults for
+using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power
+and flexibility then use the https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin[Swagger
Codegen Maven Plugin]
+directly to generate the DTO and not this plugin.
+
+The DTO classes may require additional dependencies such as:
+[source,xml]
+----
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.threeten</groupId>
+      <artifactId>threetenbp</artifactId>
+      <version>1.3.7</version>
+    </dependency>
+----
+
 === Options
 
 The plugin supports the following *additional* options
@@ -53,7 +73,11 @@ The plugin supports the following *additional* options
 |========================================
 | Parameter | Default Value | Description
 | `swaggerCodegenMavenPluginVersion` | 2.3.1 | The version of the `io.swagger:swagger-codegen-maven-plugin`
maven plugin to be used.
+| `modelOutput` | | Target output path (default is ${project.build.directory}/generated-sources/swagger)
 | `modelPackage` | `io.swagger.client.model` | The package to use for generated model objects/classes
+| `modelNamePrefix` | | Sets the pre- or suffix for model classes and enums
+| `modelNameSuffix` | | Sets the pre- or suffix for model classes and enums
+| `modelWithXml` | true | Enable XML annotations inside the generated models (only works
with ibraries that provide support for JSON and XML)
 |========================================
 
 
@@ -86,6 +110,26 @@ Works as `generate-xml` goal but also generates DTO model classes by automatic
e
 the swagger-codegen-maven-plugin to generate java source code of the DTO model classes
 from the swagger specification.
 
+This plugin has been scoped and limited to only support a good effort set of defaults for
+using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power
+and flexibility then use the https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin[Swagger
Codegen Maven Plugin]
+directly to generate the DTO and not this plugin.
+
+The DTO classes may require additional dependencies such as:
+[source,xml]
+----
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.threeten</groupId>
+      <artifactId>threetenbp</artifactId>
+      <version>1.3.7</version>
+    </dependency>
+----
+
 === Options
 
 The plugin supports the following *additional* options
@@ -93,6 +137,10 @@ The plugin supports the following *additional* options
 |========================================
 | Parameter | Default Value | Description
 | `swaggerCodegenMavenPluginVersion` | 2.3.1 | The version of the `io.swagger:swagger-codegen-maven-plugin`
maven plugin to be used.
+| `modelOutput` | | Target output path (default is ${project.build.directory}/generated-sources/swagger)
 | `modelPackage` | `io.swagger.client.model` | The package to use for generated model objects/classes
+| `modelNamePrefix` | | Sets the pre- or suffix for model classes and enums
+| `modelNameSuffix` | | Sets the pre- or suffix for model classes and enums
+| `modelWithXml` | true | Enable XML annotations inside the generated models (only works
with ibraries that provide support for JSON and XML)
 |========================================
 
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 5ed1126..bf4f63d 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
@@ -65,9 +65,21 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
     @Parameter(defaultValue = "2.3.1")
     String swaggerCodegenMavenPluginVersion;
 
+    @Parameter(defaultValue = "${project.build.directory}/generated-sources/swagger")
+    String modelOutput;
+
     @Parameter
     String modelPackage;
 
+    @Parameter
+    String modelNamePrefix;
+
+    @Parameter
+    String modelNameSuffix;
+
+    @Parameter(defaultValue = "true")
+    String modelWithXml;
+
     @Parameter(defaultValue = "${project}", readonly = true)
     private MavenProject mavenProject;
 
@@ -131,9 +143,21 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
         elements.add(new MojoExecutor.Element("generateModelTests", "false"));
         elements.add(new MojoExecutor.Element("generateModelDocumentation", "false"));
         elements.add(new MojoExecutor.Element("generateSupportingFiles", "false"));
+        if (modelOutput != null) {
+            elements.add(new MojoExecutor.Element("output", modelOutput));
+        }
         if (modelPackage != null) {
             elements.add(new MojoExecutor.Element("modelPackage", modelPackage));
         }
+        if (modelNamePrefix != null) {
+            elements.add(new MojoExecutor.Element("modelNamePrefix", modelNamePrefix));
+        }
+        if (modelNameSuffix != null) {
+            elements.add(new MojoExecutor.Element("modelNameSuffix", modelNameSuffix));
+        }
+        if (modelWithXml != null) {
+            elements.add(new MojoExecutor.Element("withXml", modelPackage));
+        }
 
         executeMojo(
             plugin(


Mime
View raw message