openapi-generator

OpenAPIToolsApache-2.0活跃维护

根据 OpenAPI 规范(v2/v3)自动生成 API 客户端 SDK、服务端桩代码、文档和配置,省去手写重复代码的麻烦。

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

v7.27.0发布于 2026-11-02 05:17 UTC26,856star +6 / 7 天7,754fork同步于 2026-11-10 05:21 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
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
curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > ~/bin/openapitools/openapi-generator-cli
brew tap AdoptOpenJDK/openjdk
brew install --cask adoptopenjdk11
硬件要求按 README 关键词推断
支持 Apple Silicon有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v7.27.0
  1. v7.27.0v7.27.0 released最新正式版2026-11-02 · 2026-11-02 05:17 UTC

    v7.27.0 stable release comes with 170+ enhancements and bug fixes.

    Below are the highlights of the changes. For a full list of changes, please refer to the "Pull Request" tab.

    General

    • [DefaultCodegen] fix unescaped description for request body #25502
    • Update jackson related dependencies to newer version in the root project #25460
    • [core] Keep integer minimum/maximum next to $ref/allOf as integers #25441
    • Fix inline Map response examples being treated as media types #25254
    • [core] Fix OAS 3.1 typed map misclassified as free-form object (#25224) #25229
    • [core] Normalizer: x-items extension for List customization #25105

    ASCII documentation

    • [asciidoc] fix: preserve multi-line descriptions in table cells #25498

    C#

    • [csharp][generichost] Raise correct error on discriminator read failures #25500
    • [csharp][restsharp] Add useClientFactory option to reuse HttpClient across requests #25482
    • [csharp][generichost] Skip unset optional string enums and write null enums #25330
    • [csharp] Fix compile errors when schema names collide with framework types #25272
    • [csharp][generichost] Refactor custom DateTime formats (dateFormat and dateTimeFormat options are deprecated) (Breaking change (with fallback)) #25213

    C++

    • [cpp-httplib-server] Generate and compile a spec without models #25279
    • fix(cpp-httplib-server): handle missing optional JSON properties #25225

    Dart

    • [dart-dio] Skip null optional form params and JSON-encode model form params #25307

    Elixir

    • [Elixir] Percent-encode path parameters in generated API functions #25366
    • [Elixir] Fall back to embedded templates when a custom template directory is set #25365
    • [elixir] Fix "clauses with the same name and arity" warning in request_builder.ex #25335

    Go

    • [Go] fix: add testify dependency to go.mod and go.sum unconditionally #25497
    • fix(go): avoid iOS build suffix in generated filename #25489

    Java

    • [Java] Match implicitHeadersRegex case insensitively #25483
    • [Java][jaxrs-spec] Annotate nullable @JsonCreator/@JsonbCreator parameters with JSpecify #25439
    • [Java][Spring] Do not generate required args constructor that duplicates @lombok.AllArgsConstructor #25396
    • [Java][Spring] useRecords: records with additionalProperties #25387
    • [Java][Spring] useRecords: records as parameter objects #25351
    • [Java][Spring] useRecords: oneOf members as records #25273
    • [Java][Spring] Add useRecords: generate plain models as records #25200
    • [Java][JAX-RS] Add JSON-B support to jaxrs-spec #25177
    • [SPRING;KOTLIN-SPRING] fix: shift 1-based page default/bounds to Spring's 0-based page index #25171

    Kotlin

    • Fix nullable items in nested Kotlin arrays #25493
    • [kotlin] Fix the kotlinx serializer for a number branch in oneOf/anyOf wrappers #25472
    • [kotlin][jvm-retrofit2] Use @HTTP with hasBody for DELETE operations with a request body #25469
    • [kotlin] Add MicroProfile REST client support #25374
    • [SPRING;KOTLIN-SPRING] fix: shift 1-based page default/bounds to Spring's 0-based page index #25171

    PHP

    • [php][php-nextgen] Support Guzzle 8 alongside Guzzle 7 #25468
    • [php-nextgen] Serialize booleans in query strings as true/false by default #25312
    • [php-nextgen] Use unknown default case when deserializing unknown enum values #25266

    PostgreSql

    • Refactor of PostgresqlSchemaCodegen; generated output is unchanged #25431

    Python

    • fix(python-flask, python-aiohttp): generated tests send apiKey under keyParamName in its declared location #25485
    • fix(python-flask, python-aiohttp): generate valid security function names for scheme names with '-' or '.' #25458
    • [python] Fix regex patterns starting with forward slash #25413
    • fix(python): generate valid code for webhooks with parameters #25346
    • REMOVE support to python3.10 #25306
    • Add support to python 3.15 #25304
    • Share Python l
  2. v7.26.0v7.26.0 released2026-10-06 · 2026-10-06 09:33 UTC
    查看更新说明

    v7.26.0 stable release comes with 240+ enhancements and bug fixes.

    Below are the highlights of the changes. For a full list of changes, please refer to the "Pull Request" tab.

    General

    • Fix property handling in OpenAPINormalizer #25104
    • Fix all ofs with nullable properties in OpenAPI 3.1 specs #25064
    • [core] - [GRADLE-PLUGIN] Add schemaLocations (ConfigurableFileCollection) and expose schema tracking via extension DSL #24979
    • fix(core) handle mismatching discriminatorType in oneOf interfaces #24812

    C#

    • [aspnetcore] Add .NET 10 support for aspnetcore #25124
    • [csharp] Serialize header parameters with content: application/json as JSON #25083
    • [csharp] Fix oneOf/anyOf response deserialization in httpclient library #25080
    • [csharp][generichost] Add support for IHostApplicationBuilder #24952
    • [csharp][generichost] Correct error message on serialization #24933
    • fix(csharp): throw JsonException from generated converters on invalid JSON #24820

    C++

    • fix(cpp-httplib-server): generate top-level enum models #24795
    • feat(cpp-boost-beast-server): add HTTP/1.1 server generator #24783
    • feat(cpp-boost-beast): add OAS 3.1 schema validation #24760

    Dart

    • [dart] fix: handle multiline x-enum-descriptions #24881
    • [dart] fix: explode object query parameters #24868
    • [dart-dio][json_serializable] fix unknownEnumValue for collection-typed enum properties #24673

    Elixir

    • [elixir] Fix cookie parameters, header serialization, optional body comma, and undeclared 2xx responses #24841
    • [elixir] Add library option with Req-based client (tesla remains default) #24840

    Go

    • fix(go): validate string enum exclusions #25089
    • [go] fix: explode object query parameters #24797

    Java

    • feat(java): support useJackson3 for rest-assured library #25077
    • fix(java): validate string enum values excluded by not #25066
    • [Java] Annotation on List items, @NotNull for example #25049
    • [BUG][JAVA] Fix generation of complex default values #25001
    • [Java] fix: map the OAS 3.1 null type to Object, not a never-generated ModelNull 24935
    • [Java][jaxrs-spec] - Add JSpecify support #24885
    • [Java][microprofile] - Add JSpecify support #24884

    Julia

    • [julia] Emit Project.toml, track OpenAPI.jl release-0.2, fix exportOperations #24789

    Kotlin

    • fix(kotlin-misk): remove nonexistent models project #25026
    • [kotlin-spring] Add clientRegistrationId option for declarative HTTP interface #25013
    • [kotlin] add additionalEnumTypeAnnotations option #24987
    • [kotlin] Fix inline enum array parameter default values #24940
    • [kotlin] fix: enumUnknownDefaultCase's moshi fallback adapters break nullable enum fields #24894
    • [kotlin-spring] seal allOf discriminator parent interfaces by default#23953

    PHP

    • [php-symfony] add compatibility with Symfony 8 #25111
    • [php-nextgen] Respect composerPackageName Config Option #24943
    • [php] fix: enumUnknownDefaultCase declares the unknown-default member but never deserializes to it #24878

    Python

    • fix(python): validate string enum values excluded by not #25070
    • Add source folder variable to Python Client #24980
    • [Python] Add HTTPX2 client library support #24966
    • [python-fastapi] add useExternalImplementationPackage to reference an external absolue impl package #24955
    • [python] fix: explode object query parameters #24802

    R

    • [R] fix: use correct 5xx error message variable in rlang::abort #24818

    Ruby

    • Set minimum required Ruby version to 2.7 #24992
    • [ruby] fix: build_from_hash drops every attribute inherited from an allOf parent #24892
    • [ruby] fix: enumUnknownDefaultCase declares the unknown-default member but never deserializes to it #24879
    • [ruby] fix: explode object query parameters #24869

    Rust

    • [rust] Name a oneOf member without a title or type after its base type #25017
    • fix(rust-server): Pass content-type wh
  3. v7.25.0v7.25.0 released2026-08-24 · 2026-08-24 08:18 UTC
    查看更新说明

    v7.25.0 stable release (breaking changes with fallbacks) comes with 240+ enhancements and bug fixes.

    Below are the highlights of the changes. For a full list of changes, please refer to the "Pull Request" tab.

    General

    • Update parser to newer version (2.1.46) #24731
    • Fix missing imports for schemaMapping in API interfaces #24672
    • [GRADLE-WRAPPER] Generator status message visibility update #24670
    • Stable hash for determining if input specification changed (Maven Plugin) #24645
    • fix(normalizer): restore behavior of clearing a oneOf if the schema content cannot currently be used by the generator #24585
    • [generators] Give clients a way to inject vendor overrides #24571
    • Fix response isArray, isMap flags #24566
    • Move shared git push template to _common #24565
    • Add logic to handle any type (3.1) with additional properties #24559
    • Normalize map schema (3.1 spec) #24558
    • fix: keep allOf members that have properties alongside a validation keyword #24551
    • feat(core): add splitOperationsByContentType option to divide operations #23935

    C#

    • fix(csharp): make generichost oneOf constructors public #24700
    • [csharp][generichost] Allow property accessor overrides #24652
    • [csharp][generichost] Refactor AsModel template #24650
    • [csharp][generichost] Make host configuration optional #24451
    • [csharp][generichost] Update partial to create HttpClient #24354

    C++

    • fix(cpp-boost-beast): validate request components #24351

    Crystal

    • fix(crystal): support Crystal 1.21 #24748

    Dart

    • Fix nullable query param #24738
    • [dart] Do not convert format: date to UTC before formatting #24706
    • Fix anyOf serialization in dart-dio #24605
    • Fix Dart native nullable number deserialization (#20238) #24386
    • [BUG][DART] PATCH tri-state optional handling #23696

    Go

    • fix(go): emit the oneOf no-match error once instead of once per member #24683
    • Update go-server deps #24527
    • Fix Golang pattern validation with regex fails on commas #24349
    • fix(golang): use datatype only for enums instead of format #24337

    Java

    • [SPRING;KOTLIN-SPRING] Fix: enhance pageable parameter detection with OpenAPI reference resolution #24758
    • [JAVA] [Spring] JSpecify, fix nullable + required field #24711
    • Add support for interface only with vertx #24655
    • [Java] Fix generated build.gradle incompatible with Gradle 9 #24649
    • [Java][jaxrs] support disableDiscriminatorJsonIgnoreProperties in typeInfoAnnotation #24532
    • [jaxrs-spec][quarkus] Migrate the Jakarta path to Quarkus REST and fix file upload types #24455
    • [java][spring][kotlin-spring] Make @JsonInclude/@JsonSetter opt-in to stop overriding global ObjectMapper #24428
    • [spring-boot]: generate PreAuthorize from OpenAPI security scopes #24380
    • [BUG] [JavaSpring] Change Dangling package JavaDoc into Regular Comment Block #24278
    • [Java] Generate nullability annotations on all-args constructor parameters #24114
    • [Java] [Spring Client] Add an exception provider interface to allow for exception redefinition #23878

    Kotlin

    • [SPRING;KOTLIN-SPRING] Fix: enhance pageable parameter detection with OpenAPI reference resolution #24758
    • [FIX][KOTLIN][SPRING] mark @param:JsonProperty as required in generated models when required in open api spec #24754
    • feat(kotlin): Add support for Jackson3 and SpringBoot 4 #24709
    • [kotlin-spring] feature: Add x-extra-imports vendor extension #24638
    • [kotlin] Add = null default for optional parameters in jvm-ktor and javalin templates #24556
    • refactor(kotlin): remove unknown default enum case for inline operation enums in multiplatform library #24521
    • [java][spring][kotlin-spring] Make @JsonInclude/@JsonSetter opt-in to stop overriding global ObjectMapper #24428
    • [KOTLIN-SPRING] fix: use spring-cloud-dependencies BOM in Spring Boot 4 spring-cloud pom #24326

    PHP

    • [PHP] Re
  4. v7.24.0v7.24.0 released2026-07-20 · 2026-07-20 07:45 UTC
    查看更新说明

    v7.24.0 stable release (breaking changes with fallbacks) comes with 170+ enhancements and bug fixes.

    Below are the highlights of the changes. For a full list of changes, please refer to the "Pull Request" tab.

    General

    • fix(docker): update base image to eclipse-temurin 17.0.19 on Ubuntu 24.04 (noble) #24230
    • fix(InlineModelResolver): do not merge untitled inline schemas differing only by description #24192
    • Fix vulnerable dependency CVE-2026-54512 #24166
    • [core] Add introspection support for discovering the discriminator type in a oneOf allOf polymorphic structure #24158
    • refactor: introduce DiscriminatorUtils to separate handling of discriminator discoverability #24143
    • fix: normalize OAS 3.1 schemas with type:[object,"null"] to set nullable:true correctly #24140
    • feat(spec-merge): add alternative DEEP merge mode with by-method path merging and configurable conflict resolution strategy #24100
    • [core] Restore sibling example for allOf with a single $ref (#23335) #24081
    • [core] Fix UnsupportedOperationException for oneOf members declaring x-implements (#23577) #24076
    • [CORE] - Feature: forcedGenerateSchemas — Force generation of schema-mapped or import-mapped schemas #24066
    • [Core] bug - fix OAS 3.1 nullable validation when using older "nullable: true" syntax instead of type: [null, ...] #24026
    • fix(online): thread-safe fileMap with TTL cleanup, SLF4J logging, and Content-Length header #24011
    • [BUG][core] Normalize OAS 3.1 type: null map value (additionalProperties) under NORMALIZE_31SPEC #23967
    • Add validate Mojo to Maven Plugin #23911
    • feat: add quiet mode to suppress verbose generation output #23831

    asciidoc

    • fix(asciidoc): escape table cell pipes in generated docs #24184

    avro

    • fix(avro): order "null" first in union when default is null #24135

    C++

    • fix(cpp-httplib-server): serialize enums using spec values #24187
    • C++ Boost.Beast client generator with OpenAPI 3.1 support #24335

    C#

    • fix(aspnetcore): remove obsolete wwwroot README #24283
    • [csharp][generichost] Refactor duplicate apis #24273
    • [csharp][generichost] Revert to DropWrite #24080
    • [csharp][generichost] Add OnCreated to JsonConverter #24079

    Crystal

    • [Crystal] Add request-signing seam (Configuration#sign_request) #24221
    • [Crystal] idiomatic api redesign #24070

    Dart

    • Dart2 class and enum improvements #24286
    • [dart-dio][built_value] Register BuilderFactory for nested additionalProperties shapes #24154
    • [dart-dio][built_value] Honor optional non-nullable properties in deserialize_properties.mustache #23661
    • [dart-dio] Fix webhook imports generating Map-style strings #22611

    Go

    • fix(golang): make object values nullable when specified #24265
    • fix(go-server): allow zero values for required request body fields #24262
    • fix(go-server): skip readOnly fields in AssertXxxRequired #24257
    • fix(go-server): use operationId consistently to fix uncompilable output for duplicate operationIds #24169
    • [Go] Honor generateUnmarshalJSON=false for oneOf models #24062

    Java

    • [Java][apache-httpclient] Apply connect timeout to requests, add read timeout support #24284
    • [java][microprofile] Extend useSealedOneOfInterfaces support to the microprofile library #24267
    • [java][microprofile] Extend support for useOneOfInterfaces to the microprofile library when Jackson serialisation is enabled #24190
    • [java][jaxrs-spec] - Add support for sealed classes and interfaces with useSealed flag #24189
    • [KOTLIN-SPRING;JAVA-SPRING] bugfix: update JsonInclude annotations for optional+nullable fields to handle serialization correctly when openApiNullable = true #24185
    • [java][jaxrs-spec][quarkus] - Add support for OneOfInterfaces & fix JsonTypeName value resolution #24174
    • Convert maintained JAX-RS samples to JUnit 5 #24173
    • fix: normalize Java annotation vendo
  5. v7.23.0v7.23.0 released2026-06-08 · 2026-06-08 13:35 UTC
    查看更新说明

    v7.23.0 stable release (breaking changes with fallbacks) comes with 170+ enhancements and bug fixes.

    This release comes with 2 breaking changes (with fallback):

    Below are the highlights of the changes. For a full list of changes, please refer to the "Pull Request" tab.

    General

    • Normalizer: new rule LOOSE_NULL_DEFINITIONS to allow more null definitions in 3.0 spec. #23932
    • fix(InlineModelResolver): prevent numbered duplicate models from multi-file OAS 3.1 specs #23856
    • fix(core): normalize OAS 3.1 content media schemas #23851
    • [GRADLE-WRAPPER] feat: add configurable worker isolation and max heap size for code generation #23648 by
    • [GRADLE-WRAPPER] bug fix - pass maven java_home to gradle correctly #23646
    • Add security schemes filter normalizer option #23174

    C#

    • [csharp][generichost] Deserialize present-but-null nullable enums #23912
    • [csharp] Fix HTTP signature auth failure on .NET 8 when query params contain special characters #23714
    • [csharp][restsharp] add throwOnAnyError option to surface client errors #23663
    • Fix/csharp reserved headers and file parameter not serialising correctly #23593
    • [csharp] Extend HostConfiguration with additional AddApiHttpClients signatures #22500

    Dart

    • feat(dart): make requests abortable #23930
    • [Dart] Preserve uppercase names with trailing digits #23894
    • [BUG][DART] fix nullable nested array item handling #23365

    Go

    • fix(go): avoid duplicate unknown enum defaults #23909
    • [go] support io.Reader and []byte response types in client decode #23789

    Java

    • [Java][restclient] Build XmlMapper via builder when useJackson3=true #23872
    • [Java] [vertx] Allow PoolOptions configuration when vertx 5 #23829
    • feat(java/jersey3): add jackson 3 support #23819
    • feat(java/jersey3): Update jakarta annotation and validation libs #23810
    • [JAVA-SPRING] spring http interface library should support 'useBeanValidation' #23803
    • [jaxrs-spec][quarkus] Emit @PermitAll for unauthenticated operations (op/global empty security, anonymous OR alternative, no security defined) #23782
    • [JavaJaxRS] [CXF] Add Support for Jackson3 #23767
    • [jaxrs-spec][quarkus] Emit @RolesAllowed({scope}) for OAuth2 and OpenID Connect operations with explicit scopes #23752
    • [jaxrs-spec][quarkus] - Add CLI flag (useQuarkusSecurityAnnotations) to enable emitting security annotation (@Authenticated, @RolesAllowed, @PermitAll) #23699
    • [JAVA-SPRING;KOTLIN-SPRING] feature - add support for 'substituteGenericPagedModel' also for 'spring-cloud' libraries #23690
    • [jaxrs-spec][quarkus] Emit @RolesAllowed({"**"}) for HTTP Basic, Bearer, api-key and OAuth2 or OpenID with empty scopes and rename "useQuarkusSecurityAnnotations" to "useJakartaSecurityAnnotations" (Breaking change (with fallback)) #23680
    • [jaxrs-spec][quarkus]: Emit @ResponseStatus annotation for 2XX success codes #23673
    • [Java] [vertx] Make supportVertxFuture compatible with vertx 5 #23660
    • Fix Jspecify nullable issue with spring boot 4 #23649
    • [java][spring] fix: disableDiscriminatorJsonIgnoreProperties not working #23640
    • [java] Support 'time-local' format #23555
    • [java] Support 'date-time-local' format #23395
    • [Spring] Add clientRegistrationId

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Stable releases in Maven Central Apache 2.0 License Open Collective backers Join the Slack chat room Follow OpenAPI Generator Twitter account to get the latest update Contribute with Gitpod Conan Center Revved up by Develocity

    Master (7.28.0): Integration Test2 Bitrise

    :star::star::star: If you would like to contribute, please refer to guidelines and a list of open tasks. :star::star::star:

    :bangbang: To migrate from Swagger Codegen to OpenAPI Generator, please refer to the migration guide :bangbang:

    :notebook_with_decorative_cover: For more information, please refer to the Wiki page and FAQ :notebook_with_decorative_cover:

    :notebook_with_decorative_cover: The eBook A Beginner's Guide to Code Generation for REST APIs is a good starting point for beginners :notebook_with_decorative_cover:

    :warning: If the OpenAPI spec, templates or any input (e.g. options, environment variables) is obtained from an untrusted source or environment, please make sure you've reviewed these inputs before using OpenAPI Generator to generate the API client, server stub or documentation to avoid potential security issues (e.g. code injection). For security vulnerabilities, please contact [email protected]. :warning:

    :bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang:

    Sponsors

    If you find OpenAPI Generator useful for work, please consider asking your company to support this Open Source project by becoming a sponsor. You can also individually sponsor the project by becoming a backer.

    Thank you to our bronze sponsors!

    Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS, Checkly for sponsoring the API monitoring and Gradle for sponsoring Develocity

    Overview

    OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:

    Languages/Frameworks
    API clientsActionScript, Ada, Apex, Bash, C, C# (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), C++ (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), Clojure, Crystal, Dart, Elixir, Elm, Eiffel, Erlang, Go, Groovy, Haskell (http-client, Servant), Java (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, Spring 6 RestClient, MicroProfile Rest Client, Helidon), Jetbrains HTTP Client, Julia, k6, Kotlin, Lua, N4JS, Nim, Node.js/JavaScript (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), Objective-C, OCaml, Perl, PHP, PowerShell, Python, R, Ruby, Rust (hyper, reqwest, rust-server), Scala (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), Swift (2.x, 3.x, 4.x, 5.x, 6.x), Typescript (AngularJS, Angular (9.x - 19.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), XoJo, Zapier
    Server stubsAda, C# (ASP.NET Core, Azure Functions), C++ (Httplib, Oat++, Pistache, Restbed, Qt5 QHTTPEngine), Erlang, F# (Giraffe), Go (net/http, Gin, Echo), Haskell (Servant, Yesod), Java (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, PKMST, Vert.x, Apache Camel, Helidon), Julia, Kotlin (Spring Boot, Ktor, Vert.x), PHP (Flight, Laravel, Lumen, Mezzio (fka Zend Expressive), Slim, Silex, Symfony), Python (FastAPI, Flask), NodeJS, Ruby (Sinatra, Rails5), Rust (rust-server), Scala (Akka, Finch, Lagom, Play, Cask, Scalatra)
    API documentation generatorsHTML, Confluence Wiki, Asciidoc, Markdown, PlantUML
    Configuration filesApache2
    OthersGraphQL, JMeter, Ktorm, MySQL Schema, Postman Collection, Protocol Buffer, WSDL

    Table of contents

    1 - Installation

    1.1 - Compatibility

    The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The openapi-generator project has the following compatibilities with the OpenAPI Specification:

    OpenAPI Generator VersionRelease DateNotes
    7.28.0 (upcoming minor release) SNAPSHOT20.11.2026Minor release with breaking changes (with fallback)
    7.27.0 (latest stable release)02.11.2026Minor release with breaking changes (with fallback)
    6.6.011.05.2023Minor release with breaking changes (with fallback)
    5.4.031.01.2022Minor release with breaking changes (with fallback)
    4.3.106.05.2020Patch release (enhancements, bug fixes, etc)

    OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0, 3.1 (beta support)

    (We do not publish daily/nightly build. Please use SNAPSHOT instead)

    For old releases, please refer to the Release page.

    For decommissioned generators/libraries/frameworks, please refer to the "Decommission" label in the pull request page.

    1.2 - Artifacts on Maven Central

    You can find our released artifacts on maven central:

    Core:

    <dependency>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator</artifactId>
        <version>${openapi-generator-version}</version>
    </dependency>
    

    See the different versions of the openapi-generator artifact available on maven central.

    Cli:

    <dependency>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-cli</artifactId>
        <version>${openapi-generator-version}</version>
    </dependency>
    

    See the different versions of the openapi-generator-cli artifact available on maven central.

    Maven plugin:

    <dependency>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${openapi-generator-version}</version>
    </dependency>
    

    Gradle plugin:

    <dependency>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-gradle-plugin</artifactId>
        <version>${openapi-generator-version}</version>
    </dependency>
    

    1.3 - Download JAR

    If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):

    JAR location: https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.27.0/openapi-generator-cli-7.27.0.jar

    For Mac/Linux users:

    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
    

    For Windows users, you will need to install wget or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.

    Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.27.0/openapi-generator-cli-7.27.0.jar
    

    After downloading the JAR, run java -jar openapi-generator-cli.jar help to show the usage.

    For Mac users, please make sure Java 11 is installed (Tips: run java -version to check the version), and export JAVA_HOME in order to use the supported Java version:

    export JAVA_HOME=`/usr/libexec/java_home -v 1.11`
    export PATH=${JAVA_HOME}/bin:$PATH
    

    Launcher Script

    One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at bin/utils/openapi-generator.cli.sh which resolves this issue.

    To install the launcher script, copy the contents of the script to a location on your path and make the script executable.

    An example of setting this up (NOTE: Always evaluate scripts curled from external systems before executing them).

    mkdir -p ~/bin/openapitools
    curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > ~/bin/openapitools/openapi-generator-cli
    chmod u+x ~/bin/openapitools/openapi-generator-cli
    export PATH=$PATH:~/bin/openapitools/
    

    Now, openapi-generator-cli is "installed". On invocation, it will query the GitHub repository for the most recently released version. If this matches the last downloaded jar, it will execute as normal. If a newer version is found, the script will download the latest release and execute it.

    If you need to invoke an older version of the generator, you can define the variable OPENAPI_GENERATOR_VERSION either ad hoc or globally. You can export this variable if you'd like to persist a specific release version.

    Examples:

    # Execute latest released openapi-generator-cli
    openapi-generator-cli version
    
    # Execute version 4.1.0 for the current invocation, regardless of the latest released version
    OPENAPI_GENERATOR_VERSION=4.1.0 openapi-generator-cli version
    
    # Execute version 4.1.0-SNAPSHOT for the current invocation
    OPENAPI_GENERATOR_VERSION=4.1.0-SNAPSHOT openapi-generator-cli version
    
    # Execute version 4.0.2 for every invocation in the current shell session
    export OPENAPI_GENERATOR_VERSION=4.0.2
    openapi-generator-cli version # is 4.0.2
    openapi-generator-cli version # is also 4.0.2
    
    # To "install" a specific version, set the variable in .bashrc/.bash_profile
    echo "export OPENAPI_GENERATOR_VERSION=4.0.2" >> ~/.bashrc
    source ~/.bashrc
    openapi-generator-cli version # is always 4.0.2, unless any of the above overrides are done ad hoc
    

    1.4 - Build Projects

    To build from source, you need the following installed and available in your $PATH:

    After cloning the project, you can build it from source using maven wrapper:

    • Linux: ./mvnw clean install
    • Windows: mvnw.cmd clean install
    Nix users

    If you're a nix user, you can enter OpenAPI Generator shell, by typing:

    nix develop
    

    It will enter a shell with Java 11 installed.

    Direnv supports automatically loading of the nix developer shell, so if you're using direnv too, type:

    direnv allow
    

    and have java and mvn set up with correct versions each time you enter project directory.

    The default build contains minimal static analysis (via CheckStyle). To run your build with PMD and Spotbugs, use the static-analysis profile:

    • Linux: ./mvnw -Pstatic-analysis clean install
    • Windows: mvnw.cmd -Pstatic-analysis clean install

    1.5 - Homebrew

    To install, run brew install openapi-generator

    Here is an example usage to generate a Ruby client:

    openapi-generator generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g ruby -o /tmp/test/
    

    To reinstall with the latest master, run brew uninstall openapi-generator && brew install --HEAD openapi-generator

    To install OpenJDK (pre-requisites), please run

    brew tap AdoptOpenJDK/openjdk
    brew install --cask adoptopenjdk11
    export JAVA_HOME=`/usr/libexec/java_home -v 1.11`
    

    or download installer via https://adoptium.net/

    To install Maven (optional), please run

    brew install maven
    

    1.6 - Docker

    Public Pre-built Docker images
    OpenAPI Generator CLI Docker Image

    The OpenAPI Generator image acts as a standalone executable. It can be used as an alternative to installing via homebrew, or for developers who are unable to install Java or upgrade the installed version.

    To generate code with this image, you'll need to mount a local location as a volume.

    Example:

    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
    

    The generated code will be located under ./out/go in the current directory.

    OpenAPI Generator Online Docker Image

    The openapi-generator-online image can act as a self-hosted web application and API for generating code. This container can be incorporated into a CI pipeline, and requires at least two HTTP requests and some docker orchestration to access generated code.

    Example usage:

    # Start container at port 8888 and save the container id
    > CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
    
    # allow for startup
    > sleep 10
    
    # Get the IP of the running container (optional)
    GEN_IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}'  $CID)
    
    # Execute an HTTP request to generate a Ruby client
    > curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' \
    -d '{"openAPIUrl": "https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml"}' \
    'http://localhost:8888/api/gen/clients/ruby'
    
    {"code":"c2d483.3.4672-40e9-91df-b9ffd18d22b8","link":"http://localhost:8888/api/gen/download/c2d483.3.4672-40e9-91df-b9ffd18d22b8"}
    
    # Download the generated zip file
    > wget http://localhost:8888/api/gen/download/c2d483.3.4672-40e9-91df-b9ffd18d22b8
    
    # Unzip the file
    > unzip c2d483.3.4672-40e9-91df-b9ffd18d22b8
    
    # Shutdown the openapi generator image
    > docker stop $CID && docker rm $CID
    
    Development in docker

    You can use run-in-docker.sh to do all development. This script maps your local repository to /gen in the docker container. It also maps ~/.m2/repository to the appropriate container location.

    To execute mvn package:

    git clone https://github.com/openapitools/openapi-generator
    cd openapi-generator
    ./run-in-docker.sh mvn package
    

    Build artifacts are now accessible in your working directory.

    Once built, run-in-docker.sh will act as an executable for openapi-generator-cli. To generate code, you'll need to output to a directory under /gen (e.g. /gen/out). For example:

    ./run-in-docker.sh help # Executes 'help' command for openapi-generator-cli
    ./run-in-docker.sh list # Executes 'list' command for openapi-generator-cli
    ./run-in-docker.sh generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
        -g go -o /gen/out/go-petstore -p packageName=petstore # generates go client, outputs locally to ./out/go-petstore
    
    Troubleshooting

    If an error like this occurs, just execute the mvn clean install -U command:

    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project openapi-generator: A type incompatibility occurred while executing org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test: java.lang.ExceptionInInitializerError cannot be cast to java.io.IOException

    ./run-in-docker.sh mvn clean install -U
    

    Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project openapi-generator-gradle-plugin-mvn-wrapper: org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.7-bin.zip'

    Right now: no solution for this one :|

    Run Docker in Vagrant

    Prerequisite: install Vagrant and VirtualBox.

    git clone https://github.com/openapitools/openapi-generator.git
    cd openapi-generator
    vagrant up
    vagrant ssh
    cd /vagrant
    ./run-in-docker.sh mvn package
    

    1.7 - NPM

    There is also an NPM package wrapper available for different platforms (e.g. Linux, Mac, Windows). (JVM is still required) Please see the project's README there for more information.

    Install it globally to get the CLI available on the command line:

    npm install @openapitools/openapi-generator-cli -g
    openapi-generator-cli version
    

    To use a specific version of "openapi-generator-cli"

    openapi-generator-cli version-manager set 7.27.0
    

    Or install it as dev-dependency:

    npm install @openapitools/openapi-generator-cli -D
    

    You can use locally built JARs or SNAPSHOT versions as well.

    1.8 - pip

    Platform(s): Linux, macOS, Windows Install via PyPI (java executable is needed to run):

    pip install openapi-generator-cli
    

    To install a specific version

    pip install openapi-generator-cli==7.27.0
    

    You can also install with jdk4py instead of java binary. (python>=3.10 is required)

    pip install openapi-generator-cli[jdk4py]
    

    Ref: https://github.com/openAPITools/openapi-generator-pip

    2 - Getting Started

    To generate a PHP client for petstore.yaml, please run the following

    git clone https://github.com/openapitools/openapi-generator
    cd openapi-generator
    ./mvnw clean package
    java -jar modules/openapi-generator-cli/target/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 /var/tmp/php_api_client
    

    (if you're on Windows, replace the last command with java -jar modules\openapi-generator-cli\target\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 c:\temp\php_api_client)

    You can also download the JAR (latest release) directly from maven.org

    To get a list of general options available, please run java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate

    To get a list of PHP specified options (which can be passed to the generator with a config file via the -c option), please run java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar config-help -g php

    3 - Usage

    To generate a sample client library

    You can build a client against the Petstore API as follows:

    ./bin/generate-samples.sh ./bin/configs/java-okhttp-gson.yaml
    

    (On Windows, please install GIT Bash for Windows to run the command above)

    This script uses the default library, which is okhttp-gson. It will run the generator with this command:

    java -jar modules/openapi-generator-cli/target/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 java \
      -t modules/openapi-generator/src/main/resources/Java \
      --additional-properties artifactId=petstore-okhttp-gson,hideGenerationTimestamp=true \
      -o samples/client/petstore/java/okhttp-gson
    

    with a number of options. The java options are documented here.

    You can also get the options with the help generate command (below only shows partial results):

    NAME
            openapi-generator-cli generate - Generate code with the specified
            generator.
    
    SYNOPSIS
            openapi-generator-cli generate
                    [(-a <authorization> | --auth <authorization>)]
                    [--api-name-suffix <api name suffix>] [--api-package <api package>]
                    [--artifact-id <artifact id>] [--artifact-version <artifact version>]
                    [(-c <configuration file> | --config <configuration file>)] [--dry-run]
                    [(-e <templating engine> | --engine <templating engine>)]
                    [--enable-post-process-file]
                    [(-g <generator name> | --generator-name <generator name>)]
                    [--generate-alias-as-model] [--git-host <git host>]
                    [--git-repo-id <git repo id>] [--git-user-id <git user id>]
                    [--global-property <global properties>...] [--group-id <group id>]
                    [--http-user-agent <http user agent>]
                    [(-i <spec file> | --input-spec <spec file>)]
                    [--ignore-file-override <ignore file override location>]
                    [--import-mappings <import mappings>...]
                    [--instantiation-types <instantiation types>...]
                    [--invoker-package <invoker package>]
                    [--language-specific-primitives <language specific primitives>...]
                    [--legacy-discriminator-behavior] [--library <library>]
                    [--log-to-stderr] [--minimal-update]
                    [--model-name-prefix <model name prefix>]
                    [--model-name-suffix <model name suffix>]
                    [--model-package <model package>]
                    [(-o <output directory> | --output <output directory>)] [(-p <additional properties> | --additional-properties <additional properties>)...]
                    [--package-name <package name>] [--release-note <release note>]
                    [--remove-operation-id-prefix]
                    [--reserved-words-mappings <reserved word mappings>...]
                    [(-s | --skip-overwrite)] [--server-variables <server variables>...]
                    [--skip-validate-spec] [--strict-spec <true/false strict behavior>]
                    [(-t <template directory> | --template-dir <template directory>)]
                    [--type-mappings <type mappings>...] [(-v | --verbose)]
    
    OPTIONS
            -a <authorization>, --auth <authorization>
                adds authorization headers when fetching the OpenAPI definitions
                remotely. Pass in a URL-encoded string of name:header with a comma
                separating multiple values
    
    ...... (results omitted)
    
            -v, --verbose
                verbose mode
    
    

    You can then compile and run the client, as well as unit tests against it:

    cd samples/client/petstore/java/okhttp-gson
    mvn package
    

    Other generators have samples too.

    3.1 - Customization

    Please refer to customization.md on how to customize the output (e.g. package name, version)

    3.2 - Workflow Integration (Maven, Gradle, Github, CI/CD)

    Please refer to integration.md on how to integrate OpenAPI generator with Maven, Gradle, sbt, Bazel, Github and CI/CD.

    3.3 - Online OpenAPI generator

    Here are the public online services:

    The server is sponsored by Linode Linode Logo

    (These services are beta and do not have any guarantee on service level)

    Please refer to online.md on how to run and use the openapi-generator-online - a web service for openapi-generator.

    3.4 - License information on Generated Code

    The OpenAPI Generator project is intended as a benefit for users of the Open API Specification. The project itself has the License as specified. In addition, please understand the following points:

    • The templates included with this project are subject to the License.
    • Generated code is intentionally not subject to the parent project license

    When code is generated from this project, it shall be considered AS IS and owned by the user of the software. There are no warranties--expressed or implied--for generated code. You can do what you wish with it, and once generated, the code is your responsibility and subject to the licensing terms that you deem appropriate.

    3.5 - IDE Integration

    Here is a list of community-contributed IDE plug-ins that integrate with OpenAPI Generator:

    4 - Companies/Projects using OpenAPI Generator

    Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit README.md and click on the icon to edit the page.

    5 - Presentations/Videos/Tutorials/Books