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][jvm-ktor] Support nullable response types (OpenAPITools#23870)
The jvm-ktor library did not handle OpenAPI schemas that allow null
as a valid response body (e.g. anyOf: [T, {type: null}] or
allOf: [T] with nullable: true).
Two template bugs prevented this from working:
1. api.mustache used {{{returnType}}} directly, ignoring the
isNullable flag on the response property. Now it appends ? when
returnProperty.isNullable is true.
2. HttpResponse.kt.mustache hardcoded <T : Any> on every generic
type parameter. This made HttpResponse<SomeType?> invalid at
the Kotlin type-system level. Removing the : Any constraint lets
the generated code use nullable types naturally.
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-ktor/infrastructure/HttpResponse.kt.mustache
{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}suspend fun body(): T = provider.body(response)
13
-
{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}suspend fun <V:Any> typedBody(type: TypeInfo): V = provider.typedBody(response, type)
13
+
{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}suspend fun <V> typedBody(type: TypeInfo): V = provider.typedBody(response, type)
0 commit comments