Skip to content

Commit

Permalink
chore(deps): Bump com.github.gantsign.maven:ktlint-maven-plugin from …
Browse files Browse the repository at this point in the history
…3.2.0 to 3.3.0 in /generator (#402)
  • Loading branch information
dependabot[bot] authored Dec 1, 2024
1 parent 7579f5b commit eb40154
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<!-- Plugin Versions -->
<exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
<ktlint-plugin.version>3.2.0</ktlint-plugin.version>
<ktlint-plugin.version>3.3.0</ktlint-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ internal data class Discriminator(
val value: String,
)

internal fun getParentDiscriminator(model: CodegenModel): Discriminator? {
return model.parentModel?.discriminator?.let {
internal fun getParentDiscriminator(model: CodegenModel): Discriminator? =
model.parentModel?.discriminator?.let {
Discriminator(
it.propertyBaseName,
it.propertyName,
it.mappedModels.find { mappedModel -> mappedModel.modelName.equals(model.classname) }!!.mappingName,
)
}
}

internal fun getDiscriminators(model: CodegenModel): MutableList<String> {
val discriminators: MutableList<String> = model.parentModel?.let { getDiscriminators(model.parentModel) } ?: mutableListOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ package com.expediagroup.sdk.generators.openapi
import org.openapitools.codegen.api.TemplateDefinition
import org.openapitools.codegen.api.TemplateFileType.Model

class ModelTemplate(templateFile: String, destinationFilename: String) : TemplateDefinition(templateFile, destinationFilename) {
class ModelTemplate(
templateFile: String,
destinationFilename: String,
) : TemplateDefinition(templateFile, destinationFilename) {
init {
templateType = Model
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ val mustacheHelpers =
model.parentModel?.let {
val discriminators: MutableList<String> = getDiscriminators(model)
writer.write("super({\n")
it.allVars.filterNot { variable ->
variable.isDiscriminator || discriminators.contains(variable.baseName)
}.forEach { variable ->
writer.write("${variable.name}: ${model.classVarName}.${variable.name},\n")
}
it.allVars
.filterNot { variable ->
variable.isDiscriminator || discriminators.contains(variable.baseName)
}.forEach { variable ->
writer.write("${variable.name}: ${model.classVarName}.${variable.name},\n")
}
writer.write("})")
}
}
Expand Down
15 changes: 12 additions & 3 deletions generator/src/main/kotlin/com/expediagroup/sdk/model/Exception.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
*/
package com.expediagroup.sdk.model

open class GeneratorException(message: String, cause: Throwable? = null) : RuntimeException(message, cause)
open class GeneratorException(
message: String,
cause: Throwable? = null,
) : RuntimeException(message, cause)

class ClientGenerationException(message: String, cause: Throwable? = null) : GeneratorException(message, cause)
class ClientGenerationException(
message: String,
cause: Throwable? = null,
) : GeneratorException(message, cause)

class PreProcessingException(message: String, cause: Throwable? = null) : GeneratorException(message, cause)
class PreProcessingException(
message: String,
cause: Throwable? = null,
) : GeneratorException(message, cause)

0 comments on commit eb40154

Please sign in to comment.