March 3, 2025
SDKs
Tomer Aberbach

Java/Kotlin OpenAPI decoration support

Stainless now outputs Java/Kotlin code snippets, which will be read by API reference documentation providers and displayed in your documentation.

Here is an example (binary response handling) of the code snippets:

package com.example.api.example;

import com.example.api.client.TestOrgClient;
import com.example.api.client.okhttp.TestOrgOkHttpClient;
import com.example.api.core.http.HttpResponse;
import com.example.api.models.FileContentParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
      // Configures using the `EXAMPLE_API_KEY` environment variable
      TestOrgClient client = TestOrgOkHttpClient.fromEnv();

      FileContentParams params = FileContentParams.builder()
          .fileId("file_id")
          .build();
      HttpResponse response = client.files().content(params);
    }
}