OpenAPITools/openapi-generator
Developer ToolsGenerates API clients, server stubs, docs and config from OpenAPI 2.0/3.x specifications in many languages.
What it does
OpenAPI Generator reads an OpenAPI/Swagger specification (1.x through 3.0, with beta 3.1 support) and emits code: client SDKs, server stubs, documentation, and configuration. It is a community fork of Swagger Codegen, started by more than 40 former contributors, and is aimed at API producers who need consistent clients across languages and API consumers who want generated boilerplate instead of hand-written HTTP code. It ships as a Java CLI, Maven/Gradle plugins, Docker images, a Node wrapper, and a pip package; a self-hosted web service is also available.
Quick start
A prepared Java runtime is the one hard requirement when using the CLI JAR. Java 11 is the minimum documented; Xcode-style checks do not apply here, just verify with java -version.
Download the released CLI JAR and generate a client from the Petstore example:
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.27.0/openapi-generator-cli-7.27.0.jar -O openapi-generator-cli.jar
java -jar openapi-generator-cli.jar generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g php \
-o /tmp/php_api_client
The generated PHP client ends up in /tmp/php_api_client. Swap -g php for another generator name and adjust the output directory. java -jar openapi-generator-cli.jar help generate lists general options, and config-help -g php lists generator-specific options.
Alternatives: install via Homebrew (brew install openapi-generator) or run the official CLI image without a local JVM:
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g go \
-o /local/out/go
Output is written to ./out/go on the host. The project also publishes the online image, which exposes a self-hosted HTTP API for generation workflows.
Usage constraints
- The CLI runs on the JVM. The pip and Node wrappers still need a Java executable unless the
jdk4pyextra is used; Java 11 or newer is expected for current releases. - Building from source requires Java 11 and optionally Maven 3.8.8+; the project provides a Maven wrapper, with
./mvnw clean installon Linux/macOS andmvnw.cmd clean installon Windows. - Generator behavior, options, and template structure vary by language. Options are documented per generator rather than uniformly, so check the specific generator page and
config-helpoutput. - Minor releases may include breaking changes with a fallback; pinning a version (
OPENAPI_GENERATOR_VERSIONfor the launcher script, or an explicit version for wrappers) is the practical way to stay stable across upgrades. - Generated code is deliberately not covered by the parent project's Apache-2.0 license and is provided as-is; licensing of the output is left to the user.
- The public online services at
api.openapi-generator.techandapi-latest-master.openapi-generator.techare beta and carry no service-level guarantee. - The launcher script resolves and downloads the latest release on invocation. Review it before adding it to your PATH, as its own documentation advises for scripts fetched from external locations.
Integration and customization
Maven, Gradle, sbt, Bazel, GitHub, and CI/CD integration are documented in docs/integration.md; output customization (package names, versions, templates) is covered in docs/customization.md. IDE plugins from the community exist for Eclipse, IntelliJ IDEA, Visual Studio, and VS Code. Mustache is the only fully supported embedded template format; other template engines are experimental.
HotRepo's take
The repository's own history points to a niche that is real but not universally loved: a single tool covering a very large language matrix, with 600k weekly downloads via the NPM CLI wrapper and 30M downloads of the CLI Docker image cited in the README. In a 2022 Hacker News discussion, one commenter described being drawn in by the multi-language, OpenAPI 3 ambition but frustrated by Java-centric generator authoring, painful template extension, and questionable generated project structure (comment); another reported not getting a Go struct generator to work and switching to Deepmap's oapi-codegen (comment). That criticism is balanced by the maintainer thanking the same commenter for the recommendation (reply), and by a competing SDK vendor in the thread conceding that existing OpenAPI generators were buggy and machine-readable rather than ergonomic (comment). The practical read: the broad generator coverage is the draw, but expect to evaluate output quality per language and to pin versions and customize templates when the defaults fall short.
Written by AI from the project's README, updated . The project's own docs are the source of truth.
Hacker News
You might also like
- usebruno/brunoA local-first API client that keeps request collections as plain files for version control and CI.
- fastapi/fastapiA Python web framework that turns type hints into validated, self-documenting REST APIs for backend developers.
- Balanov/equalRecords real HTTP API traffic into a replayable local sandbox and generates an OpenAPI 3.1 document from it.