diff --git a/api/library/kotlin-simple-api-client/src/commonMain/kotlin/kim/jeonghyeon/net/SimpleApiCustom.kt b/api/library/kotlin-simple-api-client/src/commonMain/kotlin/kim/jeonghyeon/net/SimpleApiCustom.kt index fc84abc7..ceeca365 100644 --- a/api/library/kotlin-simple-api-client/src/commonMain/kotlin/kim/jeonghyeon/net/SimpleApiCustom.kt +++ b/api/library/kotlin-simple-api-client/src/commonMain/kotlin/kim/jeonghyeon/net/SimpleApiCustom.kt @@ -32,8 +32,8 @@ class SimpleApiCustom internal constructor(val config: Config) { } - fun HttpClient.getAdapter(): RequestResponseAdapter? { - return feature(SimpleApiCustom)?.config?.adapter + fun getAdapter(client: HttpClient): RequestResponseAdapter? { + return client.feature(SimpleApiCustom)?.config?.adapter } val NoConfig = Config() diff --git a/api/plugin/kotlin-simple-api-gradle-service-shared/src/main/kotlin/kim/jeonghyeon/simplearchitecture/plugin/generator/ApiGenerator.kt b/api/plugin/kotlin-simple-api-gradle-service-shared/src/main/kotlin/kim/jeonghyeon/simplearchitecture/plugin/generator/ApiGenerator.kt index 774b41b5..b56a3c1a 100644 --- a/api/plugin/kotlin-simple-api-gradle-service-shared/src/main/kotlin/kim/jeonghyeon/simplearchitecture/plugin/generator/ApiGenerator.kt +++ b/api/plugin/kotlin-simple-api-gradle-service-shared/src/main/kotlin/kim/jeonghyeon/simplearchitecture/plugin/generator/ApiGenerator.kt @@ -78,7 +78,7 @@ class ApiGenerator( """.trimMargin() private fun SharedKtClass.makeClassDefinition() = - "class ${getApiImplementationName(name)}(val client: HttpClient, val baseUrl: String, val requestResponseAdapter: RequestResponseAdapter?) : $name" + "class ${getApiImplementationName(name)}(val client: HttpClient, val baseUrl: String) : $name" private fun SharedKtClass.makeMainPathProperty(): String { @@ -139,6 +139,7 @@ class ApiGenerator( | ${parameters.map { it.toParameterInfo() }.joinToString(",\n ")} | ) |) + |val requestResponseAdapter: RequestResponseAdapter? = SimpleApiCustom.getAdapter(client) |return client.callApi(callInfo, if (requestResponseAdapter == null) ${if (pluginOptions.useFramework) "SimpleApiCustom.NoConfig.getArchitectureAdapter()" else "SimpleApiCustom.NoConfig.getApiAdapter()"} else requestResponseAdapter) """.trimMargin() } @@ -243,7 +244,7 @@ class ApiGenerator( import io.ktor.client.HttpClient import kim.jeonghyeon.net.* - expect inline fun HttpClient.create${pluginOptions.postFix.capitalize()}(baseUrl: String, requestResponseAdapter: RequestResponseAdapter? = SimpleApiCustom.run { getAdapter() }): T + expect inline fun HttpClient.create${pluginOptions.postFix.capitalize()}(baseUrl: String): T """.trimIndent() ) @@ -272,10 +273,10 @@ class ApiGenerator( |${joinToString("\n") { "import ${if (it.packageName.isEmpty()) "" else "${it.packageName}."}${it.name}" }} |${joinToString("\n") { "import ${if (it.packageName.isEmpty()) "" else "${it.packageName}."}${it.name}Impl" }} | - |${if (pluginOptions.isMultiplatform) "actual " else ""}inline fun HttpClient.create${pluginOptions.postFix.capitalize()}(baseUrl: String, requestResponseAdapter: RequestResponseAdapter?${if (pluginOptions.isMultiplatform) "" else " = SimpleApiCustom.run { getAdapter() }"}): T { + |${if (pluginOptions.isMultiplatform) "actual " else ""}inline fun HttpClient.create${pluginOptions.postFix.capitalize()}(baseUrl: String): T { | | return when (T::class) { - |${joinToString("\n") { "${it.name}::class -> ${it.name}Impl(this, baseUrl, requestResponseAdapter) as T" }.prependIndent(" ")} + |${joinToString("\n") { "${it.name}::class -> ${it.name}Impl(this, baseUrl) as T" }.prependIndent(" ")} | | else -> ${getElseStatement()} | } @@ -304,9 +305,9 @@ class ApiGenerator( fun getElseStatement(): String { //api -> error("can not create " + T::class.simpleName) - //architecture -> createSimple(baseUrl, requestResponseAdapter) - //other with api -> createSimple(baseUrl, requestResponseAdapter) - //other with architecture -> createSimpleFramework(baseUrl, requestResponseAdapter) + //architecture -> createSimple(baseUrl) + //other with api -> createSimple(baseUrl) + //other with architecture -> createSimpleFramework(baseUrl) val isApi = pluginOptions.isInternal && !pluginOptions.useFramework val isArchitecture = pluginOptions.isInternal && pluginOptions.useFramework val isOtherWithApi = !pluginOptions.isInternal && !pluginOptions.useFramework @@ -314,9 +315,9 @@ class ApiGenerator( return if (isApi) { "error(\"can not create \" + T::class.simpleName)" } else if (isArchitecture || isOtherWithApi) { - "createSimple(baseUrl, requestResponseAdapter)" + "createSimple(baseUrl)" } else { - "createSimpleFramework(baseUrl, requestResponseAdapter)" + "createSimpleFramework(baseUrl)" } } } diff --git a/buildSrc/src/main/kotlin/DependencyVersion.kt b/buildSrc/src/main/kotlin/DependencyVersion.kt index 7ab702f6..a9798f6a 100644 --- a/buildSrc/src/main/kotlin/DependencyVersion.kt +++ b/buildSrc/src/main/kotlin/DependencyVersion.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.21" diff --git a/framework/kotlin-simple-architecture-client/build.gradle.kts b/framework/kotlin-simple-architecture-client/build.gradle.kts index 7883ec04..b7dd23b5 100644 --- a/framework/kotlin-simple-architecture-client/build.gradle.kts +++ b/framework/kotlin-simple-architecture-client/build.gradle.kts @@ -98,8 +98,8 @@ kotlin { api(deps.sqldelight.android) api(deps.android.timber) - api(deps.android.accompanist.coil) - api(deps.android.accompanist.insets) +// api(deps.android.accompanist.coil) +// api(deps.android.accompanist.insets) } } diff --git a/initializer/android-backend-api-only/buildSrc/src/main/kotlin/Dependencies.kt b/initializer/android-backend-api-only/buildSrc/src/main/kotlin/Dependencies.kt index d2f6bb7e..bb95c879 100644 --- a/initializer/android-backend-api-only/buildSrc/src/main/kotlin/Dependencies.kt +++ b/initializer/android-backend-api-only/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.20" diff --git a/initializer/android-ios-backend/buildSrc/src/main/kotlin/Dependencies.kt b/initializer/android-ios-backend/buildSrc/src/main/kotlin/Dependencies.kt index 5625c39c..b8980584 100644 --- a/initializer/android-ios-backend/buildSrc/src/main/kotlin/Dependencies.kt +++ b/initializer/android-ios-backend/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.20" diff --git a/initializer/android-ios/buildSrc/src/main/kotlin/Dependencies.kt b/initializer/android-ios/buildSrc/src/main/kotlin/Dependencies.kt index f5d6dcfe..114e0202 100644 --- a/initializer/android-ios/buildSrc/src/main/kotlin/Dependencies.kt +++ b/initializer/android-ios/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.20" diff --git a/initializer/android/buildSrc/src/main/kotlin/Dependencies.kt b/initializer/android/buildSrc/src/main/kotlin/Dependencies.kt index f5d6dcfe..114e0202 100644 --- a/initializer/android/buildSrc/src/main/kotlin/Dependencies.kt +++ b/initializer/android/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.20" diff --git a/sample/buildSrc/src/main/kotlin/Dependencies.kt b/sample/buildSrc/src/main/kotlin/Dependencies.kt index ae6ba5cf..3000249c 100644 --- a/sample/buildSrc/src/main/kotlin/Dependencies.kt +++ b/sample/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,5 +1,5 @@ object versions { - const val simpleArch = "1.4.51" + const val simpleArch = "1.4.52" object kotlin { const val version = "1.4.20"