Skip to content

Commit

Permalink
fixed error in enum description (#733)
Browse files Browse the repository at this point in the history
Co-authored-by: José Carlos Montañez <jc@MacBook-Pro.local>
  • Loading branch information
Montagon and José Carlos Montañez committed May 6, 2024
1 parent 5fb134f commit 1aef223
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,21 @@ private fun JsonObjectBuilder.applyJsonSchemaDefaults(
if (descriptor.kind == SerialKind.ENUM) {
this["enum"] = descriptor.elementNames
descriptor.elementNames
.mapIndexed { index, name ->
"$name (${descriptor.getElementAnnotations(index).lastOfInstance<Description>()?.value})"
.mapIndexedNotNull { index, name ->
val enumDescription =
descriptor.getElementAnnotations(index).lastOfInstance<Description>()?.value
if (enumDescription != null) {
"$name ($enumDescription)"
} else {
null
}
}
.joinToString("\n - ")
} else null

if (annotations.isNotEmpty()) {
val description = annotations.filterIsInstance<Description>().firstOrNull()?.value
if (additionalEnumDescription != null) {
if (!additionalEnumDescription.isNullOrEmpty()) {
this["description"] = "$description\n - $additionalEnumDescription"
} else {
this["description"] = description
Expand Down

0 comments on commit 1aef223

Please sign in to comment.