Skip to content

Commit cdd09a3

Browse files
committed
PR Feedbacks
1 parent bde67fb commit cdd09a3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

gradle-plugin/plugin/src/main/java/com/yelp/codegen/KotlinGenerator.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ open class KotlinGenerator : SharedCodegen() {
202202
return codegenModel
203203
}
204204

205-
@VisibleForTesting
206205
override fun addRequiredImports(codegenModel: CodegenModel) {
207206
// If there are any vars, we will mark them with the @Json annotation so we have to make sure to import it
208207
if (codegenModel.allVars.isNotEmpty() || codegenModel.isEnum) {

gradle-plugin/plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.yelp.codegen
22

3+
import com.google.common.annotations.VisibleForTesting
4+
import com.yelp.codegen.utils.CodegenModelVar
35
import com.yelp.codegen.utils.safeSuffix
46
import io.swagger.codegen.CodegenConfig
57
import io.swagger.codegen.CodegenModel
@@ -81,8 +83,8 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
8183
/**
8284
* Returns the /main/resources directory to access the .mustache files
8385
*/
84-
protected val resourcesDirectory: File
85-
get() = File(this.javaClass.classLoader.getResource(templateDir)!!.path.safeSuffix(File.separator))
86+
protected val resourcesDirectory: File?
87+
get() = javaClass.classLoader.getResource(templateDir)?.path?.safeSuffix(File.separator)?.let { File(it) }
8688

8789
override fun processOpts() {
8890
super.processOpts()
@@ -263,11 +265,8 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
263265

264266
// Update all enum properties datatypeWithEnum to use "BaseClass.InnerEnumClass" to reduce ambiguity
265267
CodegenModelVar.forEachVarAttribute(codegenModel) { _, properties ->
266-
properties.forEach {
267-
if (it.isEnum) {
268-
it.datatypeWithEnum = this.postProcessDataTypeWithEnum(codegenModel, it)
269-
}
270-
}
268+
properties.filter { it.isEnum }
269+
.onEach { it.datatypeWithEnum = postProcessDataTypeWithEnum(codegenModel, it) }
271270
}
272271

273272
return codegenModel
@@ -608,6 +607,7 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
608607
* Hook that allows to add the needed imports for a given [CodegenModel]
609608
* This is needed as we might be modifying models in [postProcessAllModels]
610609
*/
610+
@VisibleForTesting
611611
internal abstract fun addRequiredImports(codegenModel: CodegenModel)
612612

613613
private fun defaultListType() = typeMapping["list"] ?: ""

gradle-plugin/plugin/src/main/java/com/yelp/codegen/utils/CodegenModelVar.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.yelp.codegen.utils
2+
13
import io.swagger.codegen.CodegenModel
24
import io.swagger.codegen.CodegenProperty
35

0 commit comments

Comments
 (0)