From 70108b753e00b1268859df274173da17fea404ef Mon Sep 17 00:00:00 2001
From: Vincent Devos <46601673+karismann@users.noreply.github.com>
Date: Thu, 9 May 2019 09:19:52 +0200
Subject: [PATCH] [JAVA] fix artifactVersion is not taken from specification
(#2798)
* [JAVA] fix artifactVersion is not taken from specification when not provided by generator option
* update jaxrs-spec samples
* update docs generator jaxrs
---
docs/generators/java-msf4j.md | 2 +-
docs/generators/jaxrs-cxf-cdi.md | 2 +-
docs/generators/jaxrs-cxf-extended.md | 2 +-
docs/generators/jaxrs-cxf.md | 2 +-
docs/generators/jaxrs-jersey.md | 2 +-
docs/generators/jaxrs-resteasy-eap.md | 2 +-
docs/generators/jaxrs-resteasy.md | 2 +-
docs/generators/jaxrs-spec.md | 2 +-
.../languages/AbstractJavaCodegen.java | 73 +++++++++----------
.../AbstractJavaJAXRSServerCodegen.java | 7 +-
.../languages/JavaVertXServerCodegen.java | 4 +-
.../org/openapitools/codegen/TestUtils.java | 2 +
.../codegen/java/AbstractJavaCodegenTest.java | 23 ++++--
.../src/main/openapi/openapi.yaml | 60 +++++++++++++++
.../jaxrs-spec/src/main/openapi/openapi.yaml | 60 +++++++++++++++
15 files changed, 186 insertions(+), 59 deletions(-)
diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md
index e2e8ff10fe..bc9bb52f2f 100644
--- a/docs/generators/java-msf4j.md
+++ b/docs/generators/java-msf4j.md
@@ -45,5 +45,5 @@ sidebar_label: java-msf4j
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|
- **jersey1**
- Jersey core 1.x
- **jersey2**
- Jersey core 2.x
|jersey2|
diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md
index 5eebc16a6d..ae4443c496 100644
--- a/docs/generators/jaxrs-cxf-cdi.md
+++ b/docs/generators/jaxrs-cxf-cdi.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-cxf-cdi
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|- **<default>**
- JAXRS
|<default>|
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md
index eaf8e10765..e81cde7b51 100644
--- a/docs/generators/jaxrs-cxf-extended.md
+++ b/docs/generators/jaxrs-cxf-extended.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-cxf-extended
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|generateSpringApplication|Generate Spring application| |false|
|useSpringAnnotationConfig|Use Spring Annotation Config| |false|
|useSwaggerFeature|Use Swagger Feature| |false|
diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md
index 2e0e51438f..346dce1aa9 100644
--- a/docs/generators/jaxrs-cxf.md
+++ b/docs/generators/jaxrs-cxf.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-cxf
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|generateSpringApplication|Generate Spring application| |false|
|useSpringAnnotationConfig|Use Spring Annotation Config| |false|
|useSwaggerFeature|Use Swagger Feature| |false|
diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md
index 6ea5349811..a3172382b7 100644
--- a/docs/generators/jaxrs-jersey.md
+++ b/docs/generators/jaxrs-jersey.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-jersey
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|- **jersey1**
- Jersey core 1.x
- **jersey2**
- Jersey core 2.x
|jersey2|
|supportJava6|Whether to support Java6 with the Jersey1/2 library.| |false|
|useTags|use tags for creating interface and controller classnames| |false|
diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md
index ca41228d8c..7924fb953c 100644
--- a/docs/generators/jaxrs-resteasy-eap.md
+++ b/docs/generators/jaxrs-resteasy-eap.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-resteasy-eap
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|useBeanValidation|Use BeanValidation API annotations| |true|
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |true|
|useSwaggerFeature|Use dynamic Swagger generator| |false|
diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md
index 2e9be51a07..c85dc5cc30 100644
--- a/docs/generators/jaxrs-resteasy.md
+++ b/docs/generators/jaxrs-resteasy.md
@@ -45,5 +45,5 @@ sidebar_label: jaxrs-resteasy
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|generateJbossDeploymentDescriptor|Generate Jboss Deployment Descriptor| |false|
diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md
index 5aac1a92e8..9ea4207189 100644
--- a/docs/generators/jaxrs-spec.md
+++ b/docs/generators/jaxrs-spec.md
@@ -45,7 +45,7 @@ sidebar_label: jaxrs-spec
|implFolder|folder for generated implementation code| |src/main/java|
|title|a title describing the application| |OpenAPI Server|
|useBeanValidation|Use BeanValidation API annotations| |true|
-|serverPort|The port on which the server should be started| |null|
+|serverPort|The port on which the server should be started| |8080|
|library|library template (sub-template)|- **<default>**
- JAXRS
|<default>|
|generatePom|Whether to generate pom.xml if the file does not already exist.| |true|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index 27eedbaa83..6a1f6460ea 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -266,15 +266,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
}
- if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
- this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
- } else if (this.getVersionFromSpecification() != null) {
- this.setArtifactVersion(this.getVersionFromSpecification());
- } else {
- //not set, use to be passed to template
- additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
- }
-
if (additionalProperties.containsKey(CodegenConstants.SNAPSHOT_VERSION)) {
Boolean useSnapshotVersion = Boolean.valueOf((String) additionalProperties.get(CodegenConstants.SNAPSHOT_VERSION));
@@ -1020,8 +1011,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
List