Skip to content

Commit

Permalink
Merge pull request #34 from lightningkite/better-sdk-enum-names
Browse files Browse the repository at this point in the history
Better sdk enum names
  • Loading branch information
ethantstanger authored Mar 15, 2024
2 parents 296d74a + f4879f6 commit d882d25
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ fun Documentable.Companion.typescriptSdk(out: Appendable) = with(out) {
appendLine(" {")
for (index in 0 until it.descriptor.elementsCount) {
append(" ")
append(it.descriptor.getElementName(index))
it.descriptor.getElementName(index).first()
.let { if (it.isJavaIdentifierStart()) it else '_' }.let { append(it) }
it.descriptor.getElementName(index).drop(1)
.map { if (it.isJavaIdentifierPart()) it else '_' }.forEach { append(it) }
append(" = \"")
append(it.descriptor.getElementName(index))
append("\",")
Expand Down Expand Up @@ -426,8 +429,8 @@ private fun KSerializer<*>.write(): String = nullElement()?.let { it.write() + "
}
this.tryTypeParameterSerializers2()?.takeUnless { it.isEmpty() }
?.joinToString(", ", "<", ">") { it.write() }?.let {
out.append(it)
}
out.append(it)
}
}
}
}.toString()
Expand Down

0 comments on commit d882d25

Please sign in to comment.