Skip to content

Commit b417ce4

Browse files
committed
grpc-pb: Fix lowercase name of oneof field
Signed-off-by: Johannes Zottele <[email protected]>
1 parent 3a1134d commit b417ce4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

protoc-gen/src/main/kotlin/kotlinx/rpc/protobuf/ModelToKotlinCommonGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class ModelToKotlinCommonGenerator(
439439

440440
private fun FieldDeclaration.wireSizeCall(variable: String): String {
441441
val sizeFunc =
442-
"$PB_PKG.WireSize.${type.decodeEncodeFuncName()!!.replaceFirstChar { it.lowercase() }}($variable)"
442+
"$PB_PKG.WireSize.${type.decodeEncodeFuncName()!!.decapitalize()}($variable)"
443443
return when (val fieldType = type) {
444444
is FieldType.IntegralType -> when {
445445
fieldType.wireType == WireType.FIXED32 -> "32"

protoc-gen/src/main/kotlin/kotlinx/rpc/protobuf/codeRequestToModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private fun Descriptors.Descriptor.toModel(): MessageDeclaration = cached {
125125
regularFields = regularFields + oneOfs.map {
126126
FieldDeclaration(
127127
// TODO: Proper handling of this field name
128-
it.name.simpleName.lowercase(),
128+
it.name.simpleName.decapitalize(),
129129
FieldType.OneOf(it),
130130
doc = null,
131131
dec = it.variants.first().dec,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.rpc.protobuf
6+
7+
internal fun String.decapitalize(): String {
8+
return this.replaceFirstChar { it.lowercase() }
9+
}

0 commit comments

Comments
 (0)