From a2a7ffe2bd63ebe71699b279f9e101269f865618 Mon Sep 17 00:00:00 2001 From: CappCorp Date: Sun, 23 Jul 2017 05:34:02 +0200 Subject: [PATCH] [kotlin] fixed support of source folder (#6133) (#6134) --- .../io/swagger/codegen/languages/KotlinClientCodegen.java | 7 +++++++ .../codegen/kotlin/KotlinClientCodegenOptionsTest.java | 2 ++ .../options/KotlinClientCodegenOptionsProvider.java | 2 ++ 3 files changed, 11 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java index 2df436d195..b73d119fc5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/KotlinClientCodegen.java @@ -149,6 +149,7 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig importMapping.put("LocalTime", "java.time.LocalTime"); cliOptions.clear(); + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC).defaultValue(sourceFolder)); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. io.swagger).").defaultValue(this.packageName)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, "Client package's organization (i.e. maven groupId).").defaultValue(groupId)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "Client artifact id (name of generated jar).").defaultValue(artifactId)); @@ -191,6 +192,12 @@ public class KotlinClientCodegen extends DefaultCodegen implements CodegenConfig public void processOpts() { super.processOpts(); + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); + } else { + additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); + } + if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { this.setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } else { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenOptionsTest.java index 422326651b..55a4f8f06a 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/kotlin/KotlinClientCodegenOptionsTest.java @@ -34,6 +34,8 @@ public class KotlinClientCodegenOptionsTest extends AbstractOptionsTest { times = 1; codegen.setGroupId(KotlinClientCodegenOptionsProvider.GROUP_ID); times = 1; + codegen.setSourceFolder(KotlinClientCodegenOptionsProvider.SOURCE_FOLDER); + times = 1; }}; } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/KotlinClientCodegenOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/KotlinClientCodegenOptionsProvider.java index ae79a6d307..e27ab8a68c 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/KotlinClientCodegenOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/KotlinClientCodegenOptionsProvider.java @@ -11,6 +11,7 @@ public class KotlinClientCodegenOptionsProvider implements OptionsProvider { public static final String ARTIFACT_VERSION_VALUE = "0.0.1-SNAPSHOT"; public static final String ARTIFACT_ID = "swagger-kotlin-test"; public static final String GROUP_ID = "io.swagger.tests"; + public static final String SOURCE_FOLDER = "./generated/kotlin"; @Override public String getLanguage() { @@ -25,6 +26,7 @@ public class KotlinClientCodegenOptionsProvider implements OptionsProvider { .put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE) .put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID) .put(CodegenConstants.GROUP_ID, GROUP_ID) + .put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER) .build(); }