From ab0abe51300b51e4797a877860fa4e0fb9bd5427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Pucu=C5=82ek?= Date: Mon, 8 Mar 2021 14:38:10 +0100 Subject: [PATCH 1/2] Register StringHelpers Handlebars in AbstractKotlinCodegen.java --- .../v3/generators/kotlin/AbstractKotlinCodegen.java | 8 ++++++++ .../codegen/v3/generators/kotlin/KotlinClientCodegen.java | 1 + .../codegen/v3/generators/kotlin/KotlinServerCodegen.java | 8 -------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java index fb5937edef..f37df9ccb1 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java @@ -11,6 +11,8 @@ import io.swagger.v3.oas.models.media.Schema; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.jknack.handlebars.helper.StringHelpers; +import com.github.jknack.handlebars.Handlebars; import java.io.File; import java.util.Arrays; @@ -506,6 +508,12 @@ public String toVarName(String name) { return super.toVarName(sanitizeKotlinSpecificNames(name)); } + @Override + public void addHandlebarHelpers(Handlebars handlebars) { + super.addHandlebarHelpers(handlebars); + handlebars.registerHelpers(StringHelpers.class); + } + /** * Provides a strongly typed declaration for simple arrays of some type and arrays of arrays of some type. * diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java index b55c430108..8ca2cb1c0d 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.v3.generators.kotlin; import com.github.jknack.handlebars.Handlebars; +import com.github.jknack.handlebars.helper.StringHelpers; import com.github.jknack.handlebars.helper.ConditionalHelpers; import io.swagger.codegen.v3.CliOption; import io.swagger.codegen.v3.CodegenType; diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinServerCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinServerCodegen.java index 414166b90c..7d8800b51e 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinServerCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinServerCodegen.java @@ -18,8 +18,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import com.github.jknack.handlebars.helper.StringHelpers; -import com.github.jknack.handlebars.Handlebars; import org.apache.commons.lang3.StringUtils; import static java.util.Collections.singletonMap; @@ -228,12 +226,6 @@ public void processOpts() { supportingFiles.add(new SupportingFile("ApiKeyAuth.kt.mustache", infrastructureFolder, "ApiKeyAuth.kt")); } - @Override - public void addHandlebarHelpers(Handlebars handlebars) { - super.addHandlebarHelpers(handlebars); - handlebars.registerHelpers(StringHelpers.class); - } - @Override public String getDefaultTemplateDir() { return "kotlin-server"; From 7f85e59604b8680d8f6d16b21bd794b9d969e89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Pucu=C5=82ek?= Date: Tue, 9 Mar 2021 16:20:21 +0100 Subject: [PATCH 2/2] Remove unused import --- .../codegen/v3/generators/kotlin/KotlinClientCodegen.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java index 8ca2cb1c0d..b55c430108 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java @@ -1,7 +1,6 @@ package io.swagger.codegen.v3.generators.kotlin; import com.github.jknack.handlebars.Handlebars; -import com.github.jknack.handlebars.helper.StringHelpers; import com.github.jknack.handlebars.helper.ConditionalHelpers; import io.swagger.codegen.v3.CliOption; import io.swagger.codegen.v3.CodegenType;