Java SDK
This is the README that tungsten generates for the Java target, shown for a small example API (Swagger's Petstore). Names change with your API; the structure does not.
These recorded examples retain their original generator and runtime versions. Their installation snippets name example generated packages; they are not a current registry installation recipe. See runtime distribution for the verified stable 0.1.2 package versions and matching source routes for the unreleased 0.1.3 candidate.
Generated by tungsten 0.1.3. Java 17 or later; the runtime is io.github.pboachie.tungsten:tungsten-runtime:0.1.3 (no further dependencies).
<dependency>
<groupId>com.example</groupId>
<artifactId>openapi-sdk</artifactId>
<version>0.1.0</version>
</dependency>
Usage
import com.example.openapi.OpenapiClient;
import com.example.openapi.resources.PetsResource;
import io.github.pboachie.tungsten.runtime.*;
var client = new OpenapiClient(ClientOptions.builder()
.build());
var result = client.pets().list(PetsResource.ListRequest.builder().build(), CallOptions.defaults());
if (result instanceof Result.Err<?> err) {
System.err.println(err.error().toJson()); // the error envelope
}
Every call returns a Result: Result.Ok with the typed value and the response metadata, or Result.Err with the error envelope (Diagnostic: category, remediation, retryable, ...). Nothing throws for API or transport failures.
- Destructive and irreversible operations need
CallOptions.builder().confirm(...): a token from the operation'spreview...method, orConfirm.YESfor destructive ones. - Mutations with a caller-owned idempotency key take
idempotencyKey(...); reuse it on every retry. - Paginated operations have a
...Pagesmethod (anIterableof pages), streaming ones a...Streammethod (anEventStream: iterate it, or useon,collect,reduce,first;cancelandclose). client.dispatch()runs operations by id with JSON arguments;com.example.openapi.Opsholds the operation descriptors.
Files under src/main/java/com/example/openapi/custom/ are yours: tungsten creates the folder once and never overwrites it.