Skip to content

Commit da9ad4a

Browse files
authored
[kotlin][client] Small improvements (#15429)
* [kotlin][client] update Gradle wrapper in generated project * [kotlin][client] Add @JsonClass(generateAdapter = false) to generated enums when using moshi library This is needed, so the moshi generated R8 rules will include the enum classes: https://github.com/square/moshi#enums * [kotlin][client] Update generated samples
1 parent ef35e6d commit da9ad4a

221 files changed

Lines changed: 6725 additions & 4259 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import com.google.gson.annotations.SerializedName
44
{{/gson}}
55
{{#moshi}}
66
import com.squareup.moshi.Json
7-
{{#moshiCodeGen}}
87
import com.squareup.moshi.JsonClass
9-
{{/moshiCodeGen}}
108
{{/moshi}}
119
{{#jackson}}
1210
import com.fasterxml.jackson.annotation.JsonProperty
@@ -98,6 +96,9 @@ import {{packageName}}.infrastructure.ITransformForStorage
9896
{{#kotlinx_serialization}}
9997
{{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{#enumUnknownDefaultCase}}(with = {{classname}}Serializer::class){{/enumUnknownDefaultCase}}{{/serializableModel}}
10098
{{/kotlinx_serialization}}
99+
{{#moshi}}
100+
@JsonClass(generateAdapter = false)
101+
{{/moshi}}
101102
{{/multiplatform}}
102103
{{#multiplatform}}
103104
@Serializable

modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName
44
{{/gson}}
55
{{#moshi}}
66
import com.squareup.moshi.Json
7+
import com.squareup.moshi.JsonClass
78
{{/moshi}}
89
{{#jackson}}
910
import com.fasterxml.jackson.annotation.JsonProperty
@@ -30,6 +31,11 @@ import kotlinx.serialization.*
3031
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
3132
*/
3233
{{#multiplatform}}@Serializable{{/multiplatform}}{{#kotlinx_serialization}}@Serializable{{#enumUnknownDefaultCase}}(with = {{classname}}Serializer::class){{/enumUnknownDefaultCase}}{{/kotlinx_serialization}}
34+
{{^multiplatform}}
35+
{{#moshi}}
36+
@JsonClass(generateAdapter = false)
37+
{{/moshi}}
38+
{{/multiplatform}}
3339
{{#nonPublicApi}}internal {{/nonPublicApi}}enum class {{classname}}(val value: {{{dataType}}}) {
3440
{{#allowableValues}}{{#enumVars}}
3541
{{^multiplatform}}
@@ -62,7 +68,7 @@ import kotlinx.serialization.*
6268
{{/isArray}}
6369
{{/enumVars}}{{/allowableValues}}
6470
/**
65-
* Override toString() to avoid using the enum variable name as the value, and instead use
71+
* Override [toString()] to avoid using the enum variable name as the value, and instead use
6672
* the actual value defined in the API spec file.
6773
*
6874
* This solves a problem when the variable name and its value are different, and ensures that
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

modules/openapi-generator/src/main/resources/kotlin-client/gradlew.bat.mustache

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4041

4142
set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
44+
if %ERRORLEVEL% equ 0 goto execute
4445

4546
echo.
4647
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7576

7677
:end
7778
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
if %ERRORLEVEL% equ 0 goto mainEnd
7980

8081
:fail
8182
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8283
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
84+
set EXIT_CODE=%ERRORLEVEL%
85+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
86+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87+
exit /b %EXIT_CODE%
8588

8689
:mainEnd
8790
if "%OS%"=="Windows_NT" endlocal

0 commit comments

Comments
 (0)