Why we generate separate Kotlin and Java SDKs
Kotlin is interoperable with Java, but one SDK for both languages doesn't work in practice.
Although the Java SDK is written in Kotlin, which is interoperable with Java, its public API differs from the Kotlin SDK’s. Here are some examples:
- OpenAPI nullable schemas are exposed as
Optionaltypes for Java and nullable types for Kotlin - Lazy iterables are exposed as
Streamtypes for Java andSequencetypes for Kotlin - Async operations are exposed using
CompletableFuturetypes for Java andsuspendfunctions for Kotlin
The Java SDK is written in Kotlin because it simplifies code sharing between the Java and Kotlin SDKs, including custom code.
To add custom Java code, create a java/ directory alongside the existing kotlin/ directory. The Kotlin documentation on Java interoperability has guidance and examples you can reference to ensure your Java code works with the Kotlin code we generate.