From acadba4bfb49dd4785e23b67ef8e0784cf9014a9 Mon Sep 17 00:00:00 2001 From: Tal Kirshboim Date: Fri, 17 Dec 2021 05:12:47 +0100 Subject: [PATCH] Declare Kotlin API classes as open (#11129) --- .../libraries/multiplatform/api.mustache | 4 ++-- .../org/openapitools/client/apis/PetApi.kt | 18 +++++++++--------- .../org/openapitools/client/apis/StoreApi.kt | 10 +++++----- .../org/openapitools/client/apis/UserApi.kt | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache index c523b913d2a..7449f13a4c1 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache @@ -16,7 +16,7 @@ import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* {{#operations}} -{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}( +{{#nonPublicApi}}internal {{/nonPublicApi}}open class {{classname}}( baseUrl: String = ApiClient.BASE_URL, httpClientEngine: HttpClientEngine? = null, httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, @@ -33,7 +33,7 @@ import kotlinx.serialization.encoding.* {{#returnType}} @Suppress("UNCHECKED_CAST") {{/returnType}} - suspend fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}): HttpResponse<{{{returnType}}}{{^returnType}}Unit{{/returnType}}> { + open suspend fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}): HttpResponse<{{{returnType}}}{{^returnType}}Unit{{/returnType}}> { val localVariableAuthNames = listOf({{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}}) diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt index 1cdbc9d1052..d8bd813cbe8 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/PetApi.kt @@ -34,7 +34,7 @@ import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* -class PetApi( +open class PetApi( baseUrl: String = ApiClient.BASE_URL, httpClientEngine: HttpClientEngine? = null, httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, @@ -47,7 +47,7 @@ class PetApi( * @param body Pet object that needs to be added to the store * @return void */ - suspend fun addPet(body: Pet): HttpResponse { + open suspend fun addPet(body: Pet): HttpResponse { val localVariableAuthNames = listOf("petstore_auth") @@ -80,7 +80,7 @@ class PetApi( * @param apiKey (optional) * @return void */ - suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): HttpResponse { + open suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): HttpResponse { val localVariableAuthNames = listOf("petstore_auth") @@ -114,7 +114,7 @@ class PetApi( * @return kotlin.collections.List */ @Suppress("UNCHECKED_CAST") - suspend fun findPetsByStatus(status: kotlin.collections.List): HttpResponse> { + open suspend fun findPetsByStatus(status: kotlin.collections.List): HttpResponse> { val localVariableAuthNames = listOf("petstore_auth") @@ -158,7 +158,7 @@ class PetApi( * @return kotlin.collections.List */ @Suppress("UNCHECKED_CAST") - suspend fun findPetsByTags(tags: kotlin.collections.List): HttpResponse> { + open suspend fun findPetsByTags(tags: kotlin.collections.List): HttpResponse> { val localVariableAuthNames = listOf("petstore_auth") @@ -202,7 +202,7 @@ class PetApi( * @return Pet */ @Suppress("UNCHECKED_CAST") - suspend fun getPetById(petId: kotlin.Long): HttpResponse { + open suspend fun getPetById(petId: kotlin.Long): HttpResponse { val localVariableAuthNames = listOf("api_key") @@ -234,7 +234,7 @@ class PetApi( * @param body Pet object that needs to be added to the store * @return void */ - suspend fun updatePet(body: Pet): HttpResponse { + open suspend fun updatePet(body: Pet): HttpResponse { val localVariableAuthNames = listOf("petstore_auth") @@ -268,7 +268,7 @@ class PetApi( * @param status Updated status of the pet (optional) * @return void */ - suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): HttpResponse { + open suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): HttpResponse { val localVariableAuthNames = listOf("petstore_auth") @@ -306,7 +306,7 @@ class PetApi( * @return ModelApiResponse */ @Suppress("UNCHECKED_CAST") - suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: io.ktor.client.request.forms.InputProvider?): HttpResponse { + open suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: io.ktor.client.request.forms.InputProvider?): HttpResponse { val localVariableAuthNames = listOf("petstore_auth") diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt index ab2acfc425f..057d82fce9b 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -33,7 +33,7 @@ import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* -class StoreApi( +open class StoreApi( baseUrl: String = ApiClient.BASE_URL, httpClientEngine: HttpClientEngine? = null, httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, @@ -46,7 +46,7 @@ class StoreApi( * @param orderId ID of the order that needs to be deleted * @return void */ - suspend fun deleteOrder(orderId: kotlin.String): HttpResponse { + open suspend fun deleteOrder(orderId: kotlin.String): HttpResponse { val localVariableAuthNames = listOf() @@ -78,7 +78,7 @@ class StoreApi( * @return kotlin.collections.Map */ @Suppress("UNCHECKED_CAST") - suspend fun getInventory(): HttpResponse> { + open suspend fun getInventory(): HttpResponse> { val localVariableAuthNames = listOf("api_key") @@ -121,7 +121,7 @@ class StoreApi( * @return Order */ @Suppress("UNCHECKED_CAST") - suspend fun getOrderById(orderId: kotlin.Long): HttpResponse { + open suspend fun getOrderById(orderId: kotlin.Long): HttpResponse { val localVariableAuthNames = listOf() @@ -154,7 +154,7 @@ class StoreApi( * @return Order */ @Suppress("UNCHECKED_CAST") - suspend fun placeOrder(body: Order): HttpResponse { + open suspend fun placeOrder(body: Order): HttpResponse { val localVariableAuthNames = listOf() diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt index 83832e3cfa9..12e3221175a 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/apis/UserApi.kt @@ -33,7 +33,7 @@ import kotlinx.serialization.* import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* -class UserApi( +open class UserApi( baseUrl: String = ApiClient.BASE_URL, httpClientEngine: HttpClientEngine? = null, httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null, @@ -46,7 +46,7 @@ class UserApi( * @param body Created user object * @return void */ - suspend fun createUser(body: User): HttpResponse { + open suspend fun createUser(body: User): HttpResponse { val localVariableAuthNames = listOf() @@ -78,7 +78,7 @@ class UserApi( * @param body List of user object * @return void */ - suspend fun createUsersWithArrayInput(body: kotlin.collections.List): HttpResponse { + open suspend fun createUsersWithArrayInput(body: kotlin.collections.List): HttpResponse { val localVariableAuthNames = listOf() @@ -119,7 +119,7 @@ class UserApi( * @param body List of user object * @return void */ - suspend fun createUsersWithListInput(body: kotlin.collections.List): HttpResponse { + open suspend fun createUsersWithListInput(body: kotlin.collections.List): HttpResponse { val localVariableAuthNames = listOf() @@ -160,7 +160,7 @@ class UserApi( * @param username The name that needs to be deleted * @return void */ - suspend fun deleteUser(username: kotlin.String): HttpResponse { + open suspend fun deleteUser(username: kotlin.String): HttpResponse { val localVariableAuthNames = listOf() @@ -193,7 +193,7 @@ class UserApi( * @return User */ @Suppress("UNCHECKED_CAST") - suspend fun getUserByName(username: kotlin.String): HttpResponse { + open suspend fun getUserByName(username: kotlin.String): HttpResponse { val localVariableAuthNames = listOf() @@ -227,7 +227,7 @@ class UserApi( * @return kotlin.String */ @Suppress("UNCHECKED_CAST") - suspend fun loginUser(username: kotlin.String, password: kotlin.String): HttpResponse { + open suspend fun loginUser(username: kotlin.String, password: kotlin.String): HttpResponse { val localVariableAuthNames = listOf() @@ -260,7 +260,7 @@ class UserApi( * * @return void */ - suspend fun logoutUser(): HttpResponse { + open suspend fun logoutUser(): HttpResponse { val localVariableAuthNames = listOf() @@ -293,7 +293,7 @@ class UserApi( * @param body Updated user object * @return void */ - suspend fun updateUser(username: kotlin.String, body: User): HttpResponse { + open suspend fun updateUser(username: kotlin.String, body: User): HttpResponse { val localVariableAuthNames = listOf()