Skip to content

Commit

Permalink
PR Feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
macisamuele committed Aug 8, 2021
1 parent bde67fb commit cdd09a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ open class KotlinGenerator : SharedCodegen() {
return codegenModel
}

@VisibleForTesting
override fun addRequiredImports(codegenModel: CodegenModel) {
// If there are any vars, we will mark them with the @Json annotation so we have to make sure to import it
if (codegenModel.allVars.isNotEmpty() || codegenModel.isEnum) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yelp.codegen

import com.google.common.annotations.VisibleForTesting
import com.yelp.codegen.utils.CodegenModelVar
import com.yelp.codegen.utils.safeSuffix
import io.swagger.codegen.CodegenConfig
import io.swagger.codegen.CodegenModel
Expand Down Expand Up @@ -81,8 +83,8 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
/**
* Returns the /main/resources directory to access the .mustache files
*/
protected val resourcesDirectory: File
get() = File(this.javaClass.classLoader.getResource(templateDir)!!.path.safeSuffix(File.separator))
protected val resourcesDirectory: File?
get() = javaClass.classLoader.getResource(templateDir)?.path?.safeSuffix(File.separator)?.let { File(it) }

override fun processOpts() {
super.processOpts()
Expand Down Expand Up @@ -263,11 +265,8 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {

// Update all enum properties datatypeWithEnum to use "BaseClass.InnerEnumClass" to reduce ambiguity
CodegenModelVar.forEachVarAttribute(codegenModel) { _, properties ->
properties.forEach {
if (it.isEnum) {
it.datatypeWithEnum = this.postProcessDataTypeWithEnum(codegenModel, it)
}
}
properties.filter { it.isEnum }
.onEach { it.datatypeWithEnum = postProcessDataTypeWithEnum(codegenModel, it) }
}

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

private fun defaultListType() = typeMapping["list"] ?: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.yelp.codegen.utils

import io.swagger.codegen.CodegenModel
import io.swagger.codegen.CodegenProperty

Expand Down

0 comments on commit cdd09a3

Please sign in to comment.