[BUG][KOTLIN] Dependencies whose types are in the client's public API are declared as implementation
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- kotlin
調査の方向性
Start with kotlin-client/build.gradle.mustache and compare its dependency scopes with the multiplatform and jvm-microprofile declarations mentioned in the issue. Check which generated public API types come from those dependencies, using the listed Gradle consumer reproducer and library variants as a guide. Change the exposed dependencies to api, then confirm the consumer compiles for the reproducer and affected options.
索引モデルが issue の本文から書いたものです。
説明
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
kotlin-client/build.gradle.mustache declares the HTTP, JSON and date libraries as implementation, although their types are part of the generated client's public API. A consumer doesn't get them on its compile classpath, so code that touches those members doesn't compile. With the default jvm-okhttp4, every Api takes client: Call.Factory, ApiClient.defaultClient is an OkHttpClient and Serializer.moshi is a Moshi; in jvm-retrofit2, jvm-vertx and jvm-spring-webclient even getPetById returns such a type.
multiplatform already declares Ktor as api, and jvm-microprofile does the same for Mutiny.
openapi-generator version
7.27.0, and master at d15b0164 (7.28.0-SNAPSHOT).
OpenAPI declaration file content or url
modules/openapi-generator/src/test/resources/3_0/petstore.yaml from this repo (validate reports no issues).
Generation Details
java -jar openapi-generator-cli.jar generate -g kotlin -i petstore.yaml -o client
Steps to reproduce
A consumer next to client:
// settings.gradle
includeBuild('../client')
// build.gradle
plugins { id 'org.jetbrains.kotlin.jvm' version '2.4.0' }
repositories { mavenCentral() }
dependencies { implementation 'org.openapitools:kotlin-client:1.0.0' }
import org.openapitools.client.apis.PetApi
import org.openapitools.client.infrastructure.ApiClient
import org.openapitools.client.infrastructure.Serializer
fun main() {
val client = ApiClient.defaultClient.newBuilder().build()
println(PetApi("http://localhost", client))
println(Serializer.moshi.adapter(String::class.java).toJson("x"))
}
gradle compileKotlin on Gradle 8.14 and 9.8.2:
e: Cannot access class 'okhttp3.OkHttpClient'. Check your module classpath for missing or conflicting dependencies.
e: Cannot access class 'okhttp3.Call.Factory'. Check your module classpath for missing or conflicting dependencies.
e: Cannot access class 'com.squareup.moshi.Moshi'. Check your module classpath for missing or conflicting dependencies.
Expected: it compiles. Adding okhttp and moshi-kotlin to the consumer works around it.
Other options, same consumer setup with one call each (generated by master, Gradle 8.14):
| options | call | missing class |
|---|---|---|
moshiCodeGen=true |
Serializer.moshi.adapter(...) |
com.squareup.moshi.Moshi |
serializationLibrary=gson |
Serializer.gson.toJson(...) |
com.google.gson.Gson |
serializationLibrary=jackson |
Serializer.jacksonObjectMapper.writeValueAsString(...) |
com.fasterxml.jackson.databind.ObjectMapper |
serializationLibrary=jackson, useJackson3=true |
Serializer.jacksonObjectMapper.writeValueAsString(...) |
tools.jackson.databind.json.JsonMapper |
serializationLibrary=kotlinx_serialization |
Serializer.kotlinxSerializationJson |
kotlinx.serialization.json.Json |
dateLibrary=threetenbp |
StoreApi().getOrderById(1L).shipDate?.year |
org.threeten.bp.OffsetDateTime |
library=jvm-retrofit2 |
ApiClient().createService(PetApi::class.java).getPetById(1L).execute() |
retrofit2.Call |
library=jvm-retrofit2 |
ApiClient().getTokenEndPoint()?.setClientId("x") |
org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder |
library=jvm-retrofit2, useRxJava3=true |
...getPetById(1L).blockingGet() |
io.reactivex.rxjava3.core.Single |
library=jvm-ktor, jackson |
PetApi(httpClientConfig = { it.expectSuccess = true }) |
io.ktor.client.HttpClientConfig |
library=jvm-vertx |
api.getPetById(1L).onSuccess { } |
io.vertx.core.Future |
library=jvm-spring-webclient |
PetApi(url).getPetById(1L).block() |
reactor.core.publisher.Mono |
library=jvm-spring-restclient, useSpringBoot3=true |
Serializer.jacksonObjectMapper.writeValueAsString(...) |
com.fasterxml.jackson.databind.ObjectMapper |
I didn't build the deprecated jvm-volley, which needs the Android SDK. Its GsonRequest is public and extends com.android.volley.Request, with volley and gson also declared as implementation.
Related issues/PRs
#14113 is about the scope of another dependency (slf4j-simple).
Suggest a fix
Use api for the libraries whose types the client exposes: moshi-kotlin, moshi-adapters and moshi, gson, jackson-module-kotlin (Jackson 2 and 3), kotlinx-serialization-json, threetenbp, okhttp, retrofit, the oltu client, rxjava, ktor-client-core, vertx-core, spring-boot-starter-webflux and spring-boot-starter-web. With that change the reproducer and every call in the table compile on Gradle 8.14 and 9.8.2. The Kotlin JVM plugin already provides the api configuration.
- 主要言語
- Java
- スター
- 26.9k
- フォーク
- 7.8k
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 180
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenAPITools/openapi-generator のほかの issue
-
Issue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
OpenAPITools/openapi-generator#25643 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OpenAPITools/openapi-generator#25640 ·
メンテナーはふだん 1 日以内に返信
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)対応中かも @Inf1mum が 2 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OpenAPITools/openapi-generator#25567 ·
メンテナーはふだん 1 日以内に返信
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twice対応中かも @Inf1mum が 9 日前に担当しました。 オープンIssue: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OpenAPITools/openapi-generator#25524 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンEnhancement: Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25364 ·
メンテナーはふだん 1 日以内に返信
OpenAPITools/openapi-generator の issue をすべて見る
似ている issue
-
bug emitter:client:csharp
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/typespec#12572 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration対応中かも @amalsaidov が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
area/ai area/backend component/zeebe kind/task
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信