From f00db0a112883415b10b1484c8196c6dc8c020d4 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 00:10:46 -0800
Subject: [PATCH 01/13] fix resources management

---
 .../java/org/openapitools/codegen/AbstractGenerator.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java
index 8a3c8b09e50..1a0109b9f4d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java
@@ -40,11 +40,11 @@ public abstract class AbstractGenerator {
             File parent = new File(output.getParent());
             parent.mkdirs();
         }
-        Writer out = new BufferedWriter(new OutputStreamWriter(
-                new FileOutputStream(output), "UTF-8"));
 
-        out.write(contents);
-        out.close();
+        try (Writer out = new BufferedWriter(new OutputStreamWriter(
+                new FileOutputStream(output), "UTF-8"))) {
+            out.write(contents);
+        }
         return output;
     }
 
-- 
GitLab


From 34190a4797a4440ed936b870b2768d416e896ad1 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 00:18:49 -0800
Subject: [PATCH 02/13] remove obselete if statement

---
 .../openapitools/codegen/DefaultCodegen.java  | 36 ++-----------------
 1 file changed, 2 insertions(+), 34 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index e41d05e48f4..0fdf9dc8365 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -1251,23 +1251,7 @@ public class DefaultCodegen implements CodegenConfig {
             return schema.getExample().toString();
         }
 
-        if (ModelUtils.isBooleanSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isDateSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isDateTimeSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isNumberSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isIntegerSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isStringSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isObjectSchema(schema)) {
-            return "null";
-        } else {
-            return "null";
-        }
+        return "null";
     }
 
     /**
@@ -1282,23 +1266,7 @@ public class DefaultCodegen implements CodegenConfig {
             return schema.getDefault().toString();
         }
 
-        if (ModelUtils.isBooleanSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isDateSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isDateTimeSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isNumberSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isIntegerSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isStringSchema(schema)) {
-            return "null";
-        } else if (ModelUtils.isObjectSchema(schema)) {
-            return "null";
-        } else {
-            return "null";
-        }
+        return "null";
     }
 
     /**
-- 
GitLab


From 7b170765c5173c3b245c9c46444e829ec4b1d97e Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 00:41:30 -0800
Subject: [PATCH 03/13] throw exception when body is null

---
 .../java/org/openapitools/codegen/DefaultCodegen.java    | 1 +
 .../org/openapitools/codegen/DefaultCodegenTest.java     | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 0fdf9dc8365..e975506a9a2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -4468,6 +4468,7 @@ public class DefaultCodegen implements CodegenConfig {
     public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, String bodyParameterName) {
         if (body == null) {
             LOGGER.error("body in fromRequestBody cannot be null!");
+            throw new RuntimeException("body in fromRequestBody cannot be null!");
         }
         CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
         codegenParameter.baseName = "UNKNOWN_BASE_NAME";
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
index 7df528a0436..f95125e9ce1 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
 public class DefaultCodegenTest {
 
     @Test
-    public void testHasBodyParameter() throws Exception {
+    public void testHasBodyParameter() {
         final Schema refSchema = new Schema<>().$ref("#/components/schemas/Pet");
         Operation pingOperation = new Operation()
                 .responses(
@@ -61,6 +61,13 @@ public class DefaultCodegenTest {
         Assert.assertEquals(codegen.hasBodyParameter(openAPI, createOperation), true);
     }
 
+    @Test(expectedExceptions = RuntimeException.class)
+    public void testParameterEmptyDescription() {
+        DefaultCodegen codegen = new DefaultCodegen();
+
+        codegen.fromRequestBody(null, new HashSet<>(), null);
+    }
+
     @Test
     public void testGetConsumesInfoAndGetProducesInfo() throws Exception {
         final Schema refSchema = new Schema<>().$ref("#/components/schemas/Pet");
-- 
GitLab


From 83423a221fd3647649067e64ae35ba9a025f7689 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 00:58:36 -0800
Subject: [PATCH 04/13] prevent potentional nullpointerexception

---
 .../codegen/SpecValidationException.java      | 29 ++++++++++---------
 .../codegen/SpecValidationExceptionTest.java  | 14 +++++++++
 2 files changed, 29 insertions(+), 14 deletions(-)
 create mode 100644 modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
index f09ba918cbc..2d8e65ba993 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SpecValidationException.java
@@ -1,5 +1,6 @@
 package org.openapitools.codegen;
 
+import java.util.Optional;
 import java.util.Set;
 
 public class SpecValidationException extends RuntimeException {
@@ -105,28 +106,28 @@ public class SpecValidationException extends RuntimeException {
     @Override
     public String getMessage() {
         int errorCount = 0;
-        if (errors != null) {
-            errorCount = errors.size();
-        }
+        if (errors != null) errorCount = errors.size();
         int warningCount = 0;
-        if (warnings != null) {
-            warningCount = warnings.size();
-        }
+        if (warnings != null) warningCount = warnings.size();
 
         StringBuilder sb = new StringBuilder();
         sb.append(System.lineSeparator())
             .append("Errors: ")
             .append(System.lineSeparator());
-        errors.forEach(msg ->
-            sb.append("\t-").append(msg).append(System.lineSeparator())
-        );
 
-        if (!warnings.isEmpty()) {
+        Optional.ofNullable(errors).ifPresent(_errors -> {
+            for (String msg : errors) {
+                sb.append("\t-").append(msg).append(System.lineSeparator());
+            }
+        });
+
+        Optional.ofNullable(warnings).filter(warnings -> !warnings.isEmpty()).ifPresent(_errors -> {
             sb.append("Warnings: ").append(System.lineSeparator());
-            warnings.forEach(msg ->
-                    sb.append("\t-").append(msg).append(System.lineSeparator())
-            );
-        }
+            for (String msg : errors) {
+                sb.append("\t-").append(msg).append(System.lineSeparator());
+            }
+        });
+
         return super.getMessage() + " | " +
                 "Error count: " + errorCount + ", Warning count: " + warningCount + sb.toString();
     }
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
new file mode 100644
index 00000000000..63ab06f3869
--- /dev/null
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
@@ -0,0 +1,14 @@
+package org.openapitools.codegen;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SpecValidationExceptionTest {
+
+    @Test
+    public void shouldGetDefaultMessage() {
+        SpecValidationException specValidationException = new SpecValidationException();
+
+        Assert.assertEquals(specValidationException.getMessage(), "null | Error count: 0, Warning count: 0\nErrors: \n");
+    }
+}
\ No newline at end of file
-- 
GitLab


From 3e0e911ef425c3ae789633a9ab776c4a243dddda Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 01:02:38 -0800
Subject: [PATCH 05/13] use valueOf instead of constructor

---
 .../org/openapitools/codegen/examples/ExampleGenerator.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
index 7a56847a07b..27f0c6571fd 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
@@ -259,7 +259,7 @@ public class ExampleGenerator {
             if (ModelUtils.isFloatSchema(property)) { // float
                 return (float) randomNumber(min, max);
             } else if (ModelUtils.isDoubleSchema(property)) { // decimal/double
-                return new BigDecimal(randomNumber(min, max));
+                return BigDecimal.valueOf(randomNumber(min, max));
             } else { // no format defined
                 return randomNumber(min, max);
             }
-- 
GitLab


From f855936bd4c58c96ee555b03575b572b063c07b9 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 01:05:26 -0800
Subject: [PATCH 06/13] remove duplicated code

---
 .../codegen/examples/ExampleGenerator.java           | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
index 27f0c6571fd..30c7f20ba07 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
@@ -254,8 +254,8 @@ public class ExampleGenerator {
         } else if (ModelUtils.isDateTimeSchema(property)) {
             return "2000-01-23T04:56:07.000+00:00";
         } else if (ModelUtils.isNumberSchema(property)) {
-            Double min = property.getMinimum() == null ? null : property.getMinimum().doubleValue();
-            Double max = property.getMaximum() == null ? null : property.getMaximum().doubleValue();
+            Double min = getPropertyValue(property.getMinimum());
+            Double max = getPropertyValue(property.getMaximum());
             if (ModelUtils.isFloatSchema(property)) { // float
                 return (float) randomNumber(min, max);
             } else if (ModelUtils.isDoubleSchema(property)) { // decimal/double
@@ -267,8 +267,8 @@ public class ExampleGenerator {
             return "";  // TODO
 
         } else if (ModelUtils.isIntegerSchema(property)) {
-            Double min = property.getMinimum() == null ? null : property.getMinimum().doubleValue();
-            Double max = property.getMaximum() == null ? null : property.getMaximum().doubleValue();
+            Double min = getPropertyValue(property.getMinimum());
+            Double max = getPropertyValue(property.getMaximum());
             if (ModelUtils.isLongSchema(property)) {
                 return (long) randomNumber(min, max);
             }
@@ -319,6 +319,10 @@ public class ExampleGenerator {
         return "";
     }
 
+    private Double getPropertyValue(BigDecimal propertyValue) {
+        return propertyValue == null ? null : propertyValue.doubleValue();
+    }
+
     private double randomNumber(Double min, Double max) {
         if (min != null && max != null) {
             double range = max - min;
-- 
GitLab


From bc513689b1f1e527a61f29be1e8df255727cc635 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 01:08:11 -0800
Subject: [PATCH 07/13] avoid unclosed resources

---
 .../codegen/online/service/ZipUtil.java       | 48 +++++++++----------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/ZipUtil.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/ZipUtil.java
index ec7f6f3d77e..2719cecd1dd 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/ZipUtil.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/ZipUtil.java
@@ -51,18 +51,18 @@ public class ZipUtil {
     public void compressFiles(List<File> listFiles, String destZipFile)
             throws IOException {
 
-        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(destZipFile));
-
-        for (File file : listFiles) {
-            if (file.isDirectory()) {
-                addFolderToZip(file, file.getName(), zos);
-            } else {
-                addFileToZip(file, zos);
+        try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(destZipFile))) {
+
+            for (File file : listFiles) {
+                if (file.isDirectory()) {
+                    addFolderToZip(file, file.getName(), zos);
+                } else {
+                    addFileToZip(file, zos);
+                }
             }
-        }
 
-        zos.flush();
-        zos.close();
+            zos.flush();
+        }
     }
 
     /**
@@ -84,15 +84,12 @@ public class ZipUtil {
 
             zos.putNextEntry(new ZipEntry(parentFolder + "/" + file.getName()));
 
-            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
-
-            long bytesRead = 0;
-            byte[] bytesIn = new byte[BUFFER_SIZE];
-            int read = 0;
-
-            while ((read = bis.read(bytesIn)) != -1) {
-                zos.write(bytesIn, 0, read);
-                bytesRead += read;
+            try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
+                byte[] bytesIn = new byte[BUFFER_SIZE];
+                int read;
+                while ((read = bis.read(bytesIn)) != -1) {
+                    zos.write(bytesIn, 0, read);
+                }
             }
 
             zos.closeEntry();
@@ -112,13 +109,12 @@ public class ZipUtil {
             IOException {
         zos.putNextEntry(new ZipEntry(file.getName()));
 
-        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
-
-        byte[] bytesIn = new byte[BUFFER_SIZE];
-        int read = 0;
-
-        while ((read = bis.read(bytesIn)) != -1) {
-            zos.write(bytesIn, 0, read);
+        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
+            byte[] bytesIn = new byte[BUFFER_SIZE];
+            int read;
+            while ((read = bis.read(bytesIn)) != -1) {
+                zos.write(bytesIn, 0, read);
+            }
         }
 
         zos.closeEntry();
-- 
GitLab


From ec542f82138286fd0b70dac2aadb09627a04d4c7 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 01:10:42 -0800
Subject: [PATCH 08/13] remove redundant key

---
 .../codegen/languages/ScalaLagomServerCodegen.java             | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
index fc0c35d7b87..9b4651e601f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java
@@ -78,7 +78,7 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
         importMapping.put("DateTime", "org.joda.time.DateTime");
         importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer");
 
-        typeMapping = new HashMap<String, String>();
+        typeMapping = new HashMap<>();
         typeMapping.put("Integer", "Int");
         typeMapping.put("enum", "NSString");
         typeMapping.put("array", "Seq");
@@ -91,7 +91,6 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
         typeMapping.put("byte", "Byte");
         typeMapping.put("short", "Short");
         typeMapping.put("char", "Char");
-        typeMapping.put("long", "Long");
         typeMapping.put("double", "Double");
         typeMapping.put("object", "Any");
         typeMapping.put("file", "File");
-- 
GitLab


From e8bf6a9f0be6d82428a26263f7d463ce29a60463 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Mon, 25 Feb 2019 09:17:48 -0800
Subject: [PATCH 09/13] fix broken tests

---
 .../org/openapitools/codegen/SpecValidationExceptionTest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
index 63ab06f3869..1b490581e41 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
@@ -9,6 +9,6 @@ public class SpecValidationExceptionTest {
     public void shouldGetDefaultMessage() {
         SpecValidationException specValidationException = new SpecValidationException();
 
-        Assert.assertEquals(specValidationException.getMessage(), "null | Error count: 0, Warning count: 0\nErrors: \n");
+        Assert.assertEquals(specValidationException.getMessage(), String.format("null | Error count: 0, Warning count: 0%sErrors: %s", System.lineSeparator(), System.lineSeparator()));
     }
 }
\ No newline at end of file
-- 
GitLab


From fd7b3a06e615e5e5c7c0f5823debe1cb626f9270 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Tue, 26 Feb 2019 18:47:41 -0800
Subject: [PATCH 10/13] fix sonar issues

---
 .../codegen/languages/AbstractTypeScriptClientCodegen.java     | 3 +++
 .../codegen/languages/TypeScriptAngularClientCodegen.java      | 2 --
 .../codegen/languages/TypeScriptAxiosClientCodegen.java        | 1 -
 .../codegen/languages/TypeScriptFetchClientCodegen.java        | 1 -
 .../codegen/languages/TypeScriptInversifyClientCodegen.java    | 2 --
 .../codegen/languages/TypeScriptJqueryClientCodegen.java       | 1 -
 .../codegen/languages/TypeScriptNodeClientCodegen.java         | 1 -
 .../codegen/languages/TypeScriptRxjsClientCodegen.java         | 1 -
 8 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
index f135af4af94..54581cc2464 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -38,6 +39,8 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
 public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
     private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTypeScriptClientCodegen.class);
 
+    protected final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
+
     private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value";
     private static final String UNDEFINED_VALUE = "undefined";
 
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
index b91b1d65e4f..fb8d581ce48 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
@@ -34,8 +34,6 @@ import static org.openapitools.codegen.utils.StringUtils.*;
 public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
     private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptAngularClientCodegen.class);
 
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
-    private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value";
     private static String CLASS_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9]*$";
     private static String FILE_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9.-]*$";
 
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
index c65ef2fb9d4..0bb64748d78 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
@@ -30,7 +30,6 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen {
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
index bdec9ffeffd..e26e7a25f16 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
@@ -31,7 +31,6 @@ import java.util.Locale;
 import java.util.Map;
 
 public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen {
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
index c078a29382f..61bb8a52129 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java
@@ -31,8 +31,6 @@ import java.util.*;
 import static org.openapitools.codegen.utils.StringUtils.camelize;
 
 public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCodegen {
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
-    private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value";
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java
index 7f6c5eb0632..217f6ded902 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java
@@ -33,7 +33,6 @@ import java.util.Locale;
 
 public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodegen {
     private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptJqueryClientCodegen.class);
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
index 672a16b0b26..5735b09e47a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java
@@ -32,7 +32,6 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
 
 public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
     private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
index 56df5a82472..5f3935bcbe1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java
@@ -31,7 +31,6 @@ import java.util.Locale;
 import java.util.Map;
 
 public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen {
-    private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
 
     public static final String NPM_NAME = "npmName";
     public static final String NPM_VERSION = "npmVersion";
-- 
GitLab


From 8ea1e52ea9e3c360b3cf18c5dd9043e1cdfe9568 Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Tue, 26 Feb 2019 18:56:16 -0800
Subject: [PATCH 11/13] fix tests

---
 .../openapitools/codegen/SpecValidationExceptionTest.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
index 1b490581e41..5acf2d1a136 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/SpecValidationExceptionTest.java
@@ -9,6 +9,10 @@ public class SpecValidationExceptionTest {
     public void shouldGetDefaultMessage() {
         SpecValidationException specValidationException = new SpecValidationException();
 
-        Assert.assertEquals(specValidationException.getMessage(), String.format("null | Error count: 0, Warning count: 0%sErrors: %s", System.lineSeparator(), System.lineSeparator()));
+        String expectedResult = new StringBuffer("null | Error count: 0, Warning count: 0")
+                .append(System.lineSeparator()).append("Errors: ")
+                .append(System.lineSeparator()).toString();
+
+        Assert.assertEquals(specValidationException.getMessage(), expectedResult);
     }
 }
\ No newline at end of file
-- 
GitLab


From d4f91b2add1e386469ad5794af527762a6c32b9c Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Tue, 26 Feb 2019 21:36:11 -0800
Subject: [PATCH 12/13] add Veamly as a company using openAPI generator

---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
index 4c39a08c345..054938086cb 100644
--- a/README.md
+++ b/README.md
@@ -524,6 +524,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
 - [Telstra](https://dev.telstra.com)
 - [TUI InfoTec GmbH](http://www.tui-infotec.com/)
 - [unblu inc.](https://www.unblu.com/)
+- [Veamly](https://www.veamly.com/)
 - [Xero](https://www.xero.com/)
 - [Zalando](https://www.zalando.com)
 
-- 
GitLab


From b79305cd2e627616dcc7eb19bd378613ff9a4a4d Mon Sep 17 00:00:00 2001
From: Ramzi Maalej <ramzi@veamly.com>
Date: Sun, 3 Mar 2019 11:42:26 -0800
Subject: [PATCH 13/13] revert back if statement to explicitly express the
 intention behind it

---
 .../openapitools/codegen/DefaultCodegen.java  | 30 +++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index e975506a9a2..74bee680326 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -1251,7 +1251,7 @@ public class DefaultCodegen implements CodegenConfig {
             return schema.getExample().toString();
         }
 
-        return "null";
+        return getPropertyDefaultValue(schema);
     }
 
     /**
@@ -1266,7 +1266,33 @@ public class DefaultCodegen implements CodegenConfig {
             return schema.getDefault().toString();
         }
 
-        return "null";
+        return getPropertyDefaultValue(schema);
+    }
+
+    /**
+     * Return property value depending on property type
+     * @param schema property type
+     * @return property value
+     */
+    private String getPropertyDefaultValue(Schema schema) {
+        //NOSONAR
+        if (ModelUtils.isBooleanSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isDateSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isDateTimeSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isNumberSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isIntegerSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isStringSchema(schema)) {
+            return "null";
+        } else if (ModelUtils.isObjectSchema(schema)) {
+            return "null";
+        } else {
+            return "null";
+        }
     }
 
     /**
-- 
GitLab