You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Kotlin][Client] Add option to make all api method return a nullable model (#4422)
* Added new additional parameter to allow nullable api return types
* Tweaking samples and .bat files
I've added new .bat files for the kotlin-client to alllow windows-devs to re-generate required samples via windows-shell (for CI).
{{/allParams}}* @return {{#returnType}}{{{returnType}}}{{#nullableReturnType}} or null{{/nullableReturnType}}{{/returnType}}{{^returnType}}void{{/returnType}}
28
28
* @throws UnsupportedOperationException If the API returns an informational or redirection response
29
29
* @throws ClientException If the API returns a client error response
30
30
* @throws ServerException If the API returns a server error response
fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
34
+
fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}} {
35
35
val localVariableBody: kotlin.Any? = {{#hasBodyParam}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}mapOf({{#formParams}}"{{{baseName}}}" to "${{paramName}}"{{#hasMore}}, {{/hasMore}}{{/formParams}}){{/hasFormParams}}{{/hasBodyParam}}
36
36
val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mutableMapOf()
ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}
71
+
ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}
72
72
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
73
73
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiInfrastructureResponse.kt.mustache
0 commit comments