File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed
main/java/com/yelp/codegen
test/java/com/yelp/codegen Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 11* .iml
22. *
3- local.properties
4- venv /
53build /
4+ java_pid * .hprof
5+ local.properties
66out /
7+ venv /
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ dependencies {
2020 implementation(" com.google.guava:guava:27.0-jre" )
2121 implementation(" io.swagger:swagger-codegen:2.3.1" )
2222 implementation(" org.json:json:20180813" )
23+
24+ testImplementation(" junit:junit:4.12" )
2325}
2426
2527tasks.register<Jar >(" sourcesJar" ) {
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ class KotlinGenerator : SharedCodegen() {
319319 name
320320 } else {
321321 matchXModel(name)
322- .split( " . " ).last( )
322+ .replace( Regex ( " ( \\ .| \\ s) " ), " _ " )
323323 .toPascalCase()
324324 .sanitizeKotlinSpecificNames(specialCharReplacements)
325325 .apply { escapeReservedWord(this ) }
Original file line number Diff line number Diff line change 1+ package com.yelp.codegen
2+
3+ import org.junit.Test
4+
5+ class KotlinGeneratorTest {
6+
7+ @Test
8+ fun toModelName_doesNotTrimTooMuch () {
9+ assert (KotlinGenerator ().toModelName(" model" ) == " Model" )
10+ assert (KotlinGenerator ().toModelName(" model with space" ) == " ModelWithSpace" )
11+ assert (KotlinGenerator ().toModelName(" model with dot.s" ) == " ModelWithDotS" )
12+ assert (KotlinGenerator ().toModelName(" model with userscore_s" ) == " ModelWithUserscoreS" )
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments