SDK generation

Generate a Java SDK from OpenAPI: OpenAPI Generator vs Kiota

Two tools generate a working Java SDK from an OpenAPI spec in 2026: OpenAPI Generator (java target, with library variants like webclient and okhttp-gson) and Microsoft's Kiota. OpenAPI Generator is the safer default — a decade of production use across many library styles. Kiota's Java target reached stable-maturity code generation as of its current release and is worth a look if you want a lighter, fluent client without Spring dependencies. Sourced generates neither — pair your spec with one of the tools above, and bring Sourced in for hosted docs, llms.txt, and validation on the same spec.

OpenAPI Generator — java target, multiple library styles

OpenAPI Generator's java generator is the most flexible option because the library option controls the HTTP stack the generated client uses. Per the generator's own docs, the supported values include jersey2, jersey3, feign, feign-hc5, okhttp-gson (the default), retrofit2, resttemplate, webclient, restclient, resteasy, vertx, google-api-client, rest-assured, native, microprofile, and apache-httpclient.

The two most common picks:

  • webclient — Spring's reactive WebClient. Right choice if you're already on Spring / Spring Boot and want a non-blocking client.
  • okhttp-gson — the default, a synchronous/async OkHttp client with Gson serialization. Right choice if you're not on Spring and want fewer dependencies.

Generate with the webclient library:

openapi-generator generate -i openapi.yaml -g java -o ./generated \
  --library webclient \
  --additional-properties=artifactId=my-api-client,groupId=com.example

Or with okhttp-gson:

openapi-generator generate -i openapi.yaml -g java -o ./generated \
  --library okhttp-gson \
  --additional-properties=artifactId=my-api-client,groupId=com.example

Install via npm, Homebrew, Docker, or the jar directly — the project is on version 7.25.0 as of September 2026, per its installation docs:

# npm
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g java -o ./generated --library okhttp-gson

# Homebrew (macOS)
brew install openapi-generator
openapi-generator generate -i openapi.yaml -g java -o ./generated --library okhttp-gson

# Docker
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
  -i /local/openapi.yaml -g java -o /local/out --library okhttp-gson

Kiota — Microsoft's cross-language generator

Kiota generates fluent API clients from an OpenAPI description and is maintained by Microsoft with monthly minor releases (semver, published the first Tuesday of each month per its support docs). Its own supported-languages table currently marks Java generation, abstractions, and HTTP support as stable (the same tier as C#, Go, PHP, and Python), as of September 2026.

Install as a .NET global tool:

dotnet tool install --global Microsoft.OpenApi.Kiota

Or run it in Docker without installing anything:

docker run -v "${PWD}:/app/output" -v "${PWD}/openapi.yaml:/app/openapi.yaml" \
  mcr.microsoft.com/openapi/kiota generate --language java -n com.example.client -o /app/output

Generate a Java client directly:

kiota generate --openapi ./openapi.yaml --language java \
  --class-name ApiClient --namespace-name com.example.client --output ./generated

Kiota clients are fluent and depend on Kiota's own abstractions/HTTP/serialization packages (built on OkHttp under the hood) rather than generating a self-contained client — check what your project pulls in with kiota info -l java.

Comparison

Tool Style HTTP stack options Status (Sep 2026) Install Best for
OpenAPI Generator (java, webclient) Reactive, OO client Spring WebClient Active, v7.25.0 npm / brew / Docker / jar Spring / Spring Boot shops
OpenAPI Generator (java, okhttp-gson) Sync/async, OO client OkHttp + Gson Active, v7.25.0 (default library) npm / brew / Docker / jar Non-Spring projects, fewer deps
Kiota Fluent, request-builder style OkHttp (via Kiota abstractions) Active, Java generation stable dotnet tool / Docker / binary Teams wanting a lighter, Microsoft-maintained generator

A minimal working sequence

OpenAPI Generator, WebClient variant:

npx @openapitools/openapi-generator-cli generate \
  -i ./openapi.yaml -g java -o ./generated \
  --library webclient \
  --additional-properties=artifactId=my-api-client,groupId=com.example,java8=true

cd generated && mvn compile

That produces a Maven-buildable client with typed models under com.example, ready to mvn install into your local repo or publish to Maven Central / a private registry.

Honest scope: what Sourced does and doesn't do here

Sourced's generated SDKs focus on TypeScript and Python today — the two ecosystems where teams publish first. If Java is your target, generate it with OpenAPI Generator or Kiota as shown above, and bring Sourced in for the part of the workflow it does own: docs, llms.txt, and validation on the same spec.

What Sourced adds regardless of which Java tool you pick: give the same OpenAPI spec to Sourced's OpenAPI validator before you run codegen — the two library-option issues that most often break Java generation (missing operationId, inline schemas that produce anonymous nested classes) show up there before you've spent a build cycle finding them. Then use the same spec for hosted docs and an llms.txt file, both free and language-independent.

FAQ

Should I use OpenAPI Generator or Kiota for a Java SDK?

OpenAPI Generator, as the default. It has more library options (webclient, okhttp-gson, retrofit2, and others), a longer production track record, and doesn't require adding Kiota's own runtime abstractions as a dependency. Consider Kiota if you specifically want its fluent request-builder style or you're already using Kiota for other languages in a polyglot org.

What's the difference between the webclient and okhttp-gson libraries?

webclient generates a reactive client built on Spring's WebClient — pick it if you're on Spring / Spring Boot and want non-blocking calls. okhttp-gson (the default) generates a synchronous/async client on OkHttp with Gson for JSON — pick it if you're not on Spring, since it avoids pulling in Spring's dependency tree.

Is Kiota's Java support production-ready?

As of September 2026, Kiota's own supported-languages table marks Java generation as stable, the same tier as its C#, Go, PHP, and Python targets. It's newer to that tier than OpenAPI Generator's Java support, which has years of production use — factor that history into risk-averse decisions.

Does OpenAPI Generator's Java output need a Java runtime to build?

The generator itself needs a JVM if you run the jar directly, but the npm and Homebrew wrappers bundle that for you. The generated client code is a normal Maven/Gradle project — no dependency on the generator at build time.

Does Sourced generate Java SDKs?

No — see "Honest scope" above for what Sourced covers instead. Use OpenAPI Generator or Kiota for the Java client.

My generated Java client has anonymous nested classes for some responses — why?

That happens when a schema is inlined in the spec instead of defined under components/schemas and referenced with $ref. Every Java generator — OpenAPI Generator and Kiota included — turns an inline schema into a one-off nested type. Move shared schemas into components/schemas; see OpenAPI best practices for SDK-friendly specs for the full checklist.

Get hosted docs and llms.txt from the same spec

Whichever Java tool you pick, create hosted docs from your repo or start free with a direct OpenAPI upload — unlimited previews, up to 2 hosted noindex docs review sites and one hosted MCP server, no credit card. Run the spec through the OpenAPI validator before codegen, and if TypeScript or Python are also on your SDK list, see the TypeScript and Go generation guides.