[BUG][KOTLIN] Dependencies whose types are in the client's public API are declared as implementation
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- kotlin
- Lĩnh vực
- backend-api-design, build-system
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 26.9k
- Fork
- 7.8k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenAPITools/openapi-generator
-
Issue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
OpenAPITools/openapi-generator#25643 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Có thể đã có người làm @Inf1mum đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25567 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twiceCó thể đã có người làm @Inf1mum đã nhận 9 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
OpenAPITools/openapi-generator#25524 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởEnhancement: Feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25364 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationCó thể đã có người làm @amalsaidov đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/ai area/backend component/zeebe kind/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày