Skip to content

Commit

Permalink
Add missing SerialName to data class
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev committed Jun 12, 2024
1 parent f056d42 commit d6fd718
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions generation/src/jvmMain/kotlin/io/github/nomisrev/openapi/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,20 @@ private fun Model.Object.toTypeSpec(): TypeSpec =
Nam.toClassName(context),
properties
.map { prop ->
val propName = Nam.toPropName(prop)
ParameterSpec.builder(
Nam.toPropName(prop),
prop.model.toTypeName().copy(nullable = prop.isNullable)
)
.apply {
if (propName != prop.baseName)
addAnnotation(
annotationSpec<SerialName>()
.toBuilder()
.addMember("%S", prop.baseName)
.build()
)
}
.description(prop.description)
.defaultValue(prop.model.value)
.apply {
Expand Down

0 comments on commit d6fd718

Please sign in to comment.