From d0e2d7684dd3258233c3e4d838dcd7bf44055869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bresson?= Date: Wed, 11 Apr 2018 17:44:12 +0200 Subject: [PATCH] Getter and Setter for hideGenerationTimestamp (#7998) * Create unit test to control regressions * Change HIDE_GENERATION_TIMESTAMP handling * Add new test case: set values with the setters * Add 'isHideGenerationTimestamp()' getter --- .../io/swagger/codegen/DefaultCodegen.java | 14 ++++ .../languages/AbstractEiffelCodegen.java | 5 +- .../codegen/languages/AbstractGoCodegen.java | 4 +- .../languages/AbstractJavaCodegen.java | 3 +- .../languages/CSharpClientCodegen.java | 13 +--- .../codegen/languages/DartClientCodegen.java | 12 +--- .../languages/EiffelClientCodegen.java | 11 +-- .../codegen/languages/GoClientCodegen.java | 11 +-- .../languages/HaskellHttpClientCodegen.java | 11 ++- .../languages/JavascriptClientCodegen.java | 13 ++-- ...JavascriptClosureAngularClientCodegen.java | 10 ++- .../codegen/languages/LuaClientCodegen.java | 13 ++-- .../codegen/languages/ObjcClientCodegen.java | 13 ++-- .../codegen/languages/PerlClientCodegen.java | 10 +-- .../codegen/languages/PhpClientCodegen.java | 13 ++-- .../languages/PythonClientCodegen.java | 13 ++-- .../codegen/languages/RClientCodegen.java | 13 ++-- .../codegen/languages/RubyClientCodegen.java | 13 ++-- .../codegen/languages/RustClientCodegen.java | 13 ++-- .../codegen/languages/Swift3Codegen.java | 13 ++-- .../codegen/languages/Swift4Codegen.java | 13 +--- .../codegen/languages/SwiftCodegen.java | 12 ++-- .../languages/SymfonyServerCodegen.java | 13 ++-- .../swagger/codegen/DefaultCodegenTest.java | 36 ++++++++++ .../csharp/CSharpClientCodegenTest.java | 40 +++++++++++ .../codegen/dart/DartClientCodegenTest.java | 40 +++++++++++ .../eiffel/AbstractEiffelCodegenTest.java | 57 +++++++++++++++ .../eiffel/EiffelClientCodegenTest.java | 40 +++++++++++ .../codegen/go/AbstractGoCodegenTest.java | 57 +++++++++++++++ .../codegen/go/GoClientCodegenTest.java | 40 +++++++++++ .../HaskellHttpClientCodegenTest.java | 40 +++++++++++ .../codegen/java/AbstractJavaCodegenTest.java | 70 ++++++++++++++----- .../JavascriptClientCodegenTest.java | 40 +++++++++++ ...scriptClosureAngularClientCodegenTest.java | 40 +++++++++++ .../codegen/lua/LuaClientCodegenTest.java | 40 +++++++++++ .../codegen/objc/ObjcClientCodegenTest.java | 40 +++++++++++ .../codegen/perl/PerlClientCodegenTest.java | 40 +++++++++++ .../codegen/php/PhpClientCodegenTest.java | 40 +++++++++++ .../phpsymfony/SymfonyServerCodegenTest.java | 40 +++++++++++ .../python/PythonClientCodegenTest.java | 40 +++++++++++ .../swagger/codegen/r/RClientCodegenTest.java | 40 +++++++++++ .../codegen/ruby/RubyClientCodegenTest.java | 31 +++++++- .../codegen/rust/RustClientCodegenTest.java | 40 +++++++++++ .../codegen/swift/SwiftCodegenTest.java | 31 +++++++- .../codegen/swift3/Swift3CodegenTest.java | 30 ++++++++ .../codegen/swift4/Swift4CodegenTest.java | 30 ++++++++ 46 files changed, 1011 insertions(+), 190 deletions(-) create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/AbstractEiffelCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/go/AbstractGoCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClosureAngularClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/lua/LuaClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/phpsymfony/SymfonyServerCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/r/RClientCodegenTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/rust/RustClientCodegenTest.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 3ceaa0675ebb..08cdf4dbc464 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -128,6 +128,12 @@ public void processOpts() { this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE)); } + if (additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { + setHideGenerationTimestamp(convertPropertyToBooleanAndWriteBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP)); + } else { + additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, hideGenerationTimestamp); + } + if (additionalProperties.containsKey(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG)) { this.setSortParamsByRequiredFlag(Boolean.valueOf(additionalProperties .get(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG).toString())); @@ -3372,6 +3378,14 @@ public boolean isRemoveOperationIdPrefix() { public void setRemoveOperationIdPrefix(boolean removeOperationIdPrefix) { this.removeOperationIdPrefix = removeOperationIdPrefix; } + + public boolean isHideGenerationTimestamp() { + return hideGenerationTimestamp; + } + + public void setHideGenerationTimestamp(boolean hideGenerationTimestamp) { + this.hideGenerationTimestamp = hideGenerationTimestamp; + } /** * All library templates supported. diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractEiffelCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractEiffelCodegen.java index 723e2fb1f7eb..78961c0196d1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractEiffelCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractEiffelCodegen.java @@ -39,6 +39,9 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co public AbstractEiffelCodegen(){ super(); + + hideGenerationTimestamp = Boolean.FALSE; + setReservedWordsLowerCase(Arrays.asList( // language reserved words "across", "agent", "alias", "all", "and", "as", "assign", "attribute", "check", "class", "convert", @@ -89,7 +92,7 @@ public AbstractEiffelCodegen(){ cliOptions .add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Eiffel package version.").defaultValue("1.0.0")); cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - "hides the timestamp when files were generated").defaultValue(Boolean.TRUE.toString())); + CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString())); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractGoCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractGoCodegen.java index 62515810ba36..6b1fc44449ac 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractGoCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractGoCodegen.java @@ -28,6 +28,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege public AbstractGoCodegen() { super(); + hideGenerationTimestamp = Boolean.FALSE; + defaultIncludes = new HashSet( Arrays.asList( "map", @@ -84,7 +86,7 @@ public AbstractGoCodegen() { cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).") .defaultValue("swagger")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java index ced84fef21a3..5e5d5707d46f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java @@ -83,7 +83,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code protected String javaUtilPrefix = ""; protected Boolean serializableModel = false; protected boolean serializeBigDecimalAsString = false; - protected boolean hideGenerationTimestamp = false; protected String apiDocPath = "docs/"; protected String modelDocPath = "docs/"; protected boolean supportJava6= false; @@ -97,6 +96,8 @@ public AbstractJavaCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + hideGenerationTimestamp = false; + setReservedWordsLowerCase( Arrays.asList( // used as internal variables, can collide with parameter names diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index b4b9c0c4d489..24129e87200d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -44,7 +44,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { protected boolean supportsUWP = Boolean.FALSE; protected boolean netStandard = Boolean.FALSE; protected boolean generatePropertyChanged = Boolean.FALSE; - protected boolean hideGenerationTimestamp = Boolean.TRUE; protected boolean validatable = Boolean.TRUE; protected Map regexModifiers; @@ -62,6 +61,8 @@ public CSharpClientCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + hideGenerationTimestamp = Boolean.TRUE; + cliOptions.clear(); // CLI options @@ -188,12 +189,6 @@ public void processOpts() { setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING)); } - // default HIDE_GENERATION_TIMESTAMP to true - if (additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - setHideGenerationTimestamp(convertPropertyToBooleanAndWriteBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP)); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, hideGenerationTimestamp); - } if (isEmpty(apiPackage)) { setApiPackage("Api"); @@ -768,10 +763,6 @@ public void setGeneratePropertyChanged(final Boolean generatePropertyChanged) { this.generatePropertyChanged = generatePropertyChanged; } - public void setHideGenerationTimestamp(boolean hideGenerationTimestamp) { - this.hideGenerationTimestamp = hideGenerationTimestamp; - } - public boolean isNonPublicApi() { return nonPublicApi; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index 478431a455d1..377a8031070d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -8,7 +8,6 @@ import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; -import io.swagger.models.Model; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; @@ -52,6 +51,9 @@ public DartClientCodegen() { modelDocTemplateFiles.put("object_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( "abstract", "as", "assert", "async", "async*", "await", @@ -165,14 +167,6 @@ public void processOpts() { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java index 28d7879a0be2..68e093a07740 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java @@ -52,20 +52,15 @@ public EiffelClientCodegen() { apiTestTemplateFiles.put("test/api_test.mustache", ".e"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); embeddedTemplateDir = templateDir = "Eiffel"; + + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = true; } @Override public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } else { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 68be0c17557f..6e57f01389aa 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -33,6 +33,9 @@ public GoClientCodegen() { embeddedTemplateDir = templateDir = "go"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // data type @@ -58,14 +61,6 @@ public GoClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java index c503ce3cb624..a530878c826b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java @@ -142,6 +142,9 @@ public HaskellHttpClientCodegen() { apiPackage = "API"; //modelPackage = "Model"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + // Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords setReservedWordsLowerCase( Arrays.asList( @@ -246,7 +249,7 @@ public HaskellHttpClientCodegen() { cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime")); cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat)); - cliOptions.add(CliOption.newBoolean(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated").defaultValue(Boolean.TRUE.toString())); + cliOptions.add(CliOption.newBoolean(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString())); } @@ -340,12 +343,6 @@ private String getStringProp(String key) { @Override public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - convertPropertyToBooleanAndWriteBack(CodegenConstants.HIDE_GENERATION_TIMESTAMP); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, true); - } if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) { setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index a131a93d62f7..23aaa1de6c4a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -111,6 +111,9 @@ public JavascriptClientCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + // reference: http://www.w3schools.com/js/js_reserved.asp setReservedWordsLowerCase( Arrays.asList( @@ -192,7 +195,7 @@ public JavascriptClientCodegen() { cliOptions.add(new CliOption(USE_INHERITANCE, "use JavaScript prototype chains & delegation for inheritance") .defaultValue(Boolean.TRUE.toString())); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(USE_ES6, "use JavaScript ES6 (ECMAScript 6) (beta). Default is ES5.") @@ -223,14 +226,6 @@ public void processOpts() { } super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(PROJECT_NAME)) { setProjectName(((String) additionalProperties.get(PROJECT_NAME))); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClosureAngularClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClosureAngularClientCodegen.java index 24f6d22112b5..593bdbd3afd2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClosureAngularClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClosureAngularClientCodegen.java @@ -21,6 +21,9 @@ public JavascriptClosureAngularClientCodegen() { super(); outputFolder = "generated-code/javascript-closure-angular"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + supportsInheritance = false; setReservedWordsLowerCase(Arrays.asList("abstract", "continue", "for", "new", "switch", "assert", "default", "if", @@ -71,7 +74,7 @@ public JavascriptClosureAngularClientCodegen() { typeMapping.put("binary", "string"); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(USE_ES6, "use ES6 templates") @@ -82,11 +85,6 @@ public JavascriptClosureAngularClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } - if (additionalProperties.containsKey(USE_ES6)) { setUseEs6(convertPropertyToBooleanAndWriteBack(USE_ES6)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java index 4da35a982e64..1c65d321a424 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java @@ -47,6 +47,9 @@ public LuaClientCodegen() { embeddedTemplateDir = templateDir = "lua"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // data type @@ -109,7 +112,7 @@ public LuaClientCodegen() { .defaultValue("swagger-client")); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Lua package version.") .defaultValue("1.0.0-1")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -118,14 +121,6 @@ public LuaClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index 7d31800186b4..2e19f5799aa0 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -56,6 +56,9 @@ public ObjcClientCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + defaultIncludes.clear(); defaultIncludes.add("bool"); defaultIncludes.add("BOOL"); @@ -167,7 +170,7 @@ public ObjcClientCodegen() { cliOptions.add(new CliOption(AUTHOR_EMAIL, "Email to use in the podspec file.").defaultValue("apiteam@swagger.io")); cliOptions.add(new CliOption(GIT_REPO_URL, "URL for the git repo where this podspec should point to.") .defaultValue("https://github.com/swagger-api/swagger-codegen")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -190,14 +193,6 @@ public String getHelp() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(POD_NAME)) { setPodName((String) additionalProperties.get(POD_NAME)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index bf50765f1caf..0d741563645c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -57,6 +57,8 @@ public PerlClientCodegen() { apiDocTemplateFiles.put("api_doc.mustache", ".md"); embeddedTemplateDir = templateDir = "perl"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; setReservedWordsLowerCase( Arrays.asList( @@ -135,14 +137,6 @@ public void processOpts() { additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiClient.pm")); supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Configuration.pm")); supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiFactory.pm")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index d0a87381cded..87316270aef0 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -69,6 +69,9 @@ public PhpClientCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // local variables used in api methods (endpoints) @@ -141,7 +144,7 @@ public PhpClientCodegen() { cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release")); cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -210,14 +213,6 @@ public String getHelp() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(PACKAGE_PATH)) { this.setPackagePath((String) additionalProperties.get(PACKAGE_PATH)); } else { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index bc5e4c994ac5..07e5bf94dffa 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -63,6 +63,9 @@ public PythonClientCodegen() { testFolder = "test"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + languageSpecificPrimitives.clear(); languageSpecificPrimitives.add("int"); languageSpecificPrimitives.add("float"); @@ -127,7 +130,7 @@ public PythonClientCodegen() { cliOptions.add(new CliOption(PACKAGE_URL, "python package URL.")); cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString())); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); supportedLibraries.put("urllib3", "urllib3-based client"); @@ -171,14 +174,6 @@ public void processOpts() { setPackageVersion("1.0.0"); } - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName); additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RClientCodegen.java index d34528eaf100..f2802e806282 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RClientCodegen.java @@ -45,6 +45,9 @@ public RClientCodegen() { embeddedTemplateDir = templateDir = "r"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // reserved words: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html @@ -93,7 +96,7 @@ public RClientCodegen() { .defaultValue("swagger")); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "R package version.") .defaultValue("1.0.0")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -102,14 +105,6 @@ public RClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } else { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 1ce38ede9e25..87db2d63d6d6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -73,6 +73,9 @@ public RubyClientCodegen() { modelTestTemplateFiles.put("model_test.mustache", ".rb"); apiTestTemplateFiles.put("api_test.mustache", ".rb"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // local variable names used in API methods (endpoints) @@ -161,7 +164,7 @@ public RubyClientCodegen() { cliOptions.add(new CliOption(GEM_AUTHOR_EMAIL, "gem author email (only one is supported).")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated"). + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC). defaultValue(Boolean.TRUE.toString())); } @@ -170,14 +173,6 @@ public RubyClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(GEM_NAME)) { setGemName((String) additionalProperties.get(GEM_NAME)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RustClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RustClientCodegen.java index 473ad490479f..540452da5208 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RustClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RustClientCodegen.java @@ -47,6 +47,9 @@ public RustClientCodegen() { modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + embeddedTemplateDir = templateDir = "rust"; setReservedWordsLowerCase( @@ -109,7 +112,7 @@ public RustClientCodegen() { .defaultValue("swagger")); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Rust package version.") .defaultValue("1.0.0")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -118,14 +121,6 @@ public RustClientCodegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift3Codegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift3Codegen.java index 22642e00e29f..90c90ea688c2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift3Codegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift3Codegen.java @@ -86,6 +86,9 @@ public Swift3Codegen() { apiPackage = File.separator + "APIs"; modelPackage = File.separator + "Models"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + languageSpecificPrimitives = new HashSet<>( Arrays.asList( "Int", @@ -173,7 +176,7 @@ public Swift3Codegen() { cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec")); cliOptions.add(new CliOption(POD_DOCUMENTATION_URL, "Documentation URL used for Podspec")); cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE, "Flag to make all the API classes inner-class of {{projectName}}API")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(LENIENT_TYPE_CAST, "Accept and cast values for simple types (string->bool, string->int, int->string)") .defaultValue(Boolean.FALSE.toString())); @@ -183,14 +186,6 @@ public Swift3Codegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - // Setup project name if (additionalProperties.containsKey(PROJECT_NAME)) { setProjectName((String) additionalProperties.get(PROJECT_NAME)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift4Codegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift4Codegen.java index 54162b4e2700..2359bff54268 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift4Codegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Swift4Codegen.java @@ -241,7 +241,7 @@ public Swift4Codegen() { "Flag to make all the API classes inner-class " + "of {{projectName}}API")); cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - "hides the timestamp when files were generated") + CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(LENIENT_TYPE_CAST, "Accept and cast values for simple types (string->bool, " @@ -253,17 +253,6 @@ public Swift4Codegen() { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.TRUE.toString()); - } else { - Boolean hide = Boolean.valueOf(additionalProperties() - .get(CodegenConstants.HIDE_GENERATION_TIMESTAMP) - .toString()); - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, hide); - } - // Setup project name if (additionalProperties.containsKey(PROJECT_NAME)) { setProjectName((String) additionalProperties.get(PROJECT_NAME)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 902302833ded..8f9d0944f1ab 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -78,6 +78,9 @@ public SwiftCodegen() { apiPackage = File.separator + "APIs"; modelPackage = File.separator + "Models"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + languageSpecificPrimitives = new HashSet( Arrays.asList( "Int", @@ -163,7 +166,7 @@ public SwiftCodegen() { cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec")); cliOptions.add(new CliOption(POD_DOCUMENTATION_URL, "Documentation URL used for Podspec")); cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE, "Flag to make all the API classes inner-class of {{projectName}}API")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); } @@ -171,13 +174,6 @@ public SwiftCodegen() { @Override public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } // Setup project name if (additionalProperties.containsKey(PROJECT_NAME)) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java index b5726efc7ff8..c872fd66af4c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java @@ -81,6 +81,9 @@ public SymfonyServerCodegen() { apiTestTemplateFiles.put("testing/api_test.mustache", ".php"); embeddedTemplateDir = templateDir = "php-symfony"; + // default HIDE_GENERATION_TIMESTAMP to true + hideGenerationTimestamp = Boolean.TRUE; + setReservedWordsLowerCase( Arrays.asList( // local variables used in api methods (endpoints) @@ -148,7 +151,7 @@ public SymfonyServerCodegen() { cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets. IMPORTANT NOTE (2016/03): composerVendorName will be deprecated and replaced by gitUserId in the next swagger-codegen release")); cliOptions.add(new CliOption(BUNDLE_NAME, "The name of the Symfony bundle. The template uses {{bundleName}}")); cliOptions.add(new CliOption(COMPOSER_PROJECT_NAME, "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client. IMPORTANT NOTE (2016/03): composerProjectName will be deprecated and replaced by gitRepoId in the next swagger-codegen release")); - cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated") + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(PHP_LEGACY_SUPPORT, "Should the generated code be compatible with PHP 5.x?").defaultValue(Boolean.TRUE.toString())); } @@ -209,14 +212,6 @@ public String apiFilename(String templateName, String tag) { public void processOpts() { super.processOpts(); - // default HIDE_GENERATION_TIMESTAMP to true - if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); - } else { - additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, - Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); - } - if (additionalProperties.containsKey(BUNDLE_NAME)) { this.setBundleName((String) additionalProperties.get(BUNDLE_NAME)); } else { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultCodegenTest.java new file mode 100644 index 000000000000..be20a4d6649e --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultCodegenTest.java @@ -0,0 +1,36 @@ +package io.swagger.codegen; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class DefaultCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final DefaultCodegen codegen = new DefaultCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final DefaultCodegen codegen = new DefaultCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false ); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final DefaultCodegen codegen = new DefaultCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientCodegenTest.java new file mode 100644 index 000000000000..467850581cef --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.csharp; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.CSharpClientCodegen; + +public class CSharpClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final CSharpClientCodegen codegen = new CSharpClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final CSharpClientCodegen codegen = new CSharpClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final CSharpClientCodegen codegen = new CSharpClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientCodegenTest.java new file mode 100644 index 000000000000..a324b2573032 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/dart/DartClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.dart; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.DartClientCodegen; + +public class DartClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final DartClientCodegen codegen = new DartClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final DartClientCodegen codegen = new DartClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final DartClientCodegen codegen = new DartClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/AbstractEiffelCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/AbstractEiffelCodegenTest.java new file mode 100644 index 000000000000..8748a1e0ea0a --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/AbstractEiffelCodegenTest.java @@ -0,0 +1,57 @@ +package io.swagger.codegen.eiffel; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenType; +import io.swagger.codegen.languages.AbstractEiffelCodegen; + +public class AbstractEiffelCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final AbstractEiffelCodegen codegen = new P_AbstractEiffelCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final AbstractEiffelCodegen codegen = new P_AbstractEiffelCodegen(); + codegen.setHideGenerationTimestamp(true); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final AbstractEiffelCodegen codegen = new P_AbstractEiffelCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, true); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + private static class P_AbstractEiffelCodegen extends AbstractEiffelCodegen { + @Override + public CodegenType getTag() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public String getHelp() { + return null; + } + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientCodegenTest.java new file mode 100644 index 000000000000..5ea3d64374fc --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.eiffel; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.EiffelClientCodegen; + +public class EiffelClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final EiffelClientCodegen codegen = new EiffelClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final EiffelClientCodegen codegen = new EiffelClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final EiffelClientCodegen codegen = new EiffelClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/AbstractGoCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/AbstractGoCodegenTest.java new file mode 100644 index 000000000000..fb33e6205243 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/AbstractGoCodegenTest.java @@ -0,0 +1,57 @@ +package io.swagger.codegen.go; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenType; +import io.swagger.codegen.languages.AbstractGoCodegen; + +public class AbstractGoCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final AbstractGoCodegen codegen = new P_AbstractGoCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final AbstractGoCodegen codegen = new P_AbstractGoCodegen(); + codegen.setHideGenerationTimestamp(true); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final AbstractGoCodegen codegen = new P_AbstractGoCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, true); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + private static class P_AbstractGoCodegen extends AbstractGoCodegen { + @Override + public CodegenType getTag() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public String getHelp() { + return null; + } + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientCodegenTest.java new file mode 100644 index 000000000000..ba0db9fba3d4 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.go; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.GoClientCodegen; + +public class GoClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final GoClientCodegen codegen = new GoClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final GoClientCodegen codegen = new GoClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final GoClientCodegen codegen = new GoClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientCodegenTest.java new file mode 100644 index 000000000000..7e516cd6ec33 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.haskellhttpclient; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.HaskellHttpClientCodegen; + +public class HaskellHttpClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final HaskellHttpClientCodegen codegen = new HaskellHttpClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final HaskellHttpClientCodegen codegen = new HaskellHttpClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final HaskellHttpClientCodegen codegen = new HaskellHttpClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/AbstractJavaCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/AbstractJavaCodegenTest.java index 8147923d87cc..9ef81ef85900 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/AbstractJavaCodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/java/AbstractJavaCodegenTest.java @@ -3,29 +3,18 @@ import org.testng.Assert; import org.testng.annotations.Test; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.languages.AbstractJavaCodegen; -import io.swagger.models.*; -import io.swagger.models.parameters.*; +import io.swagger.models.Operation; +import io.swagger.models.Path; +import io.swagger.models.Swagger; +import io.swagger.models.parameters.BodyParameter; +import io.swagger.models.parameters.FormParameter; public class AbstractJavaCodegenTest { - private final AbstractJavaCodegen fakeJavaCodegen = new AbstractJavaCodegen() { - @Override - public CodegenType getTag() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public String getHelp() { - return null; - } - }; + private final AbstractJavaCodegen fakeJavaCodegen = new P_AbstractJavaCodegen(); @Test public void toEnumVarNameShouldNotShortenUnderScore() throws Exception { @@ -97,4 +86,49 @@ public void preprocessSwaggerWithNoFormOrBodyParamsDoesNotSetContentType() { Assert.assertNull(swagger.getPath("dummy").getPost().getVendorExtensions().get("x-contentType")); } + @Test + public void testInitialConfigValues() throws Exception { + final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + codegen.setHideGenerationTimestamp(true); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + private static class P_AbstractJavaCodegen extends AbstractJavaCodegen { + @Override + public CodegenType getTag() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public String getHelp() { + return null; + } + } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClientCodegenTest.java new file mode 100644 index 000000000000..7db4762aecea --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.javascript; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.JavascriptClientCodegen; + +public class JavascriptClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final JavascriptClientCodegen codegen = new JavascriptClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final JavascriptClientCodegen codegen = new JavascriptClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final JavascriptClientCodegen codegen = new JavascriptClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClosureAngularClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClosureAngularClientCodegenTest.java new file mode 100644 index 000000000000..b9cba6dd8dc1 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/javascript/JavascriptClosureAngularClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.javascript; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen; + +public class JavascriptClosureAngularClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final JavascriptClosureAngularClientCodegen codegen = new JavascriptClosureAngularClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final JavascriptClosureAngularClientCodegen codegen = new JavascriptClosureAngularClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final JavascriptClosureAngularClientCodegen codegen = new JavascriptClosureAngularClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/lua/LuaClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/lua/LuaClientCodegenTest.java new file mode 100644 index 000000000000..6df219f9f9fb --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/lua/LuaClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.lua; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.LuaClientCodegen; + +public class LuaClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final LuaClientCodegen codegen = new LuaClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final LuaClientCodegen codegen = new LuaClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final LuaClientCodegen codegen = new LuaClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientCodegenTest.java new file mode 100644 index 000000000000..6d4f0d2795c6 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.objc; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.ObjcClientCodegen; + +public class ObjcClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final ObjcClientCodegen codegen = new ObjcClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final ObjcClientCodegen codegen = new ObjcClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final ObjcClientCodegen codegen = new ObjcClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientCodegenTest.java new file mode 100644 index 000000000000..0cfce7c55db0 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/perl/PerlClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.perl; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.PerlClientCodegen; + +public class PerlClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final PerlClientCodegen codegen = new PerlClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final PerlClientCodegen codegen = new PerlClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final PerlClientCodegen codegen = new PerlClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientCodegenTest.java new file mode 100644 index 000000000000..84251091a21f --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/php/PhpClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.php; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.PhpClientCodegen; + +public class PhpClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final PhpClientCodegen codegen = new PhpClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final PhpClientCodegen codegen = new PhpClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final PhpClientCodegen codegen = new PhpClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/phpsymfony/SymfonyServerCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/phpsymfony/SymfonyServerCodegenTest.java new file mode 100644 index 000000000000..5930c2131ecd --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/phpsymfony/SymfonyServerCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.phpsymfony; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.SymfonyServerCodegen; + +public class SymfonyServerCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final SymfonyServerCodegen codegen = new SymfonyServerCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final SymfonyServerCodegen codegen = new SymfonyServerCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final SymfonyServerCodegen codegen = new SymfonyServerCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientCodegenTest.java new file mode 100644 index 000000000000..b2660d4776c2 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/python/PythonClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.python; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.PythonClientCodegen; + +public class PythonClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final PythonClientCodegen codegen = new PythonClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final PythonClientCodegen codegen = new PythonClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final PythonClientCodegen codegen = new PythonClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/r/RClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/r/RClientCodegenTest.java new file mode 100644 index 000000000000..fbe2e36199b9 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/r/RClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.r; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.RClientCodegen; + +public class RClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final RClientCodegen codegen = new RClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final RClientCodegen codegen = new RClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final RClientCodegen codegen = new RClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientCodegenTest.java index 0e226b316328..163dd3a145a4 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ruby/RubyClientCodegenTest.java @@ -3,6 +3,7 @@ import io.swagger.codegen.ClientOpts; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.DefaultGenerator; import io.swagger.codegen.languages.RubyClientCodegen; import io.swagger.models.Swagger; @@ -10,6 +11,7 @@ import org.apache.commons.io.FileUtils; import org.junit.rules.TemporaryFolder; +import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -18,7 +20,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; -import static org.junit.Assert.fail; import static org.testng.Assert.*; /** @@ -63,4 +64,32 @@ public void testGenerateRubyClientWithHtmlEntity() throws Exception { } } + @Test + public void testInitialConfigValues() throws Exception { + final RubyClientCodegen codegen = new RubyClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final RubyClientCodegen codegen = new RubyClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final RubyClientCodegen codegen = new RubyClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/rust/RustClientCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/rust/RustClientCodegenTest.java new file mode 100644 index 000000000000..5876af0d5162 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/rust/RustClientCodegenTest.java @@ -0,0 +1,40 @@ +package io.swagger.codegen.rust; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.languages.RustClientCodegen; + +public class RustClientCodegenTest { + + @Test + public void testInitialConfigValues() throws Exception { + final RustClientCodegen codegen = new RustClientCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final RustClientCodegen codegen = new RustClientCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final RustClientCodegen codegen = new RustClientCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftCodegenTest.java index 70ead616b28e..ebbefa769982 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftCodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftCodegenTest.java @@ -1,8 +1,8 @@ package io.swagger.codegen.swift; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.DefaultCodegen; -import io.swagger.codegen.InlineModelResolver; import io.swagger.codegen.languages.SwiftCodegen; import io.swagger.models.Operation; import io.swagger.models.Swagger; @@ -106,4 +106,33 @@ public void testPodAuthors() throws Exception { Assert.assertEquals(podAuthors, swaggerDevs); } + @Test + public void testInitialConfigValues() throws Exception { + final SwiftCodegen codegen = new SwiftCodegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final SwiftCodegen codegen = new SwiftCodegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final SwiftCodegen codegen = new SwiftCodegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + } \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift3/Swift3CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift3/Swift3CodegenTest.java index 86785b155f8b..e507c6020fe8 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift3/Swift3CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift3/Swift3CodegenTest.java @@ -1,5 +1,6 @@ package io.swagger.codegen.swift3; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.languages.Swift3Codegen; @@ -122,4 +123,33 @@ public void testPodAuthors() throws Exception { Assert.assertEquals(podAuthors, swaggerDevs); } + @Test + public void testInitialConfigValues() throws Exception { + final Swift3Codegen codegen = new Swift3Codegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final Swift3Codegen codegen = new Swift3Codegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final Swift3Codegen codegen = new Swift3Codegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift4/Swift4CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift4/Swift4CodegenTest.java index ff7e74006761..fcaada1eadeb 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift4/Swift4CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/swift4/Swift4CodegenTest.java @@ -1,5 +1,6 @@ package io.swagger.codegen.swift4; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.languages.Swift4Codegen; @@ -122,4 +123,33 @@ public void testPodAuthors() throws Exception { Assert.assertEquals(podAuthors, swaggerDevs); } + @Test + public void testInitialConfigValues() throws Exception { + final Swift4Codegen codegen = new Swift4Codegen(); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); + } + + @Test + public void testSettersForConfigValues() throws Exception { + final Swift4Codegen codegen = new Swift4Codegen(); + codegen.setHideGenerationTimestamp(false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + + @Test + public void testAdditionalPropertiesPutForConfigValues() throws Exception { + final Swift4Codegen codegen = new Swift4Codegen(); + codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false); + codegen.processOpts(); + + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE); + Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); + } + }