Skip to main content



A Maven plugin to support the OpenAPI generator project


Add to your build->plugins section (default phase is generate-sources phase)


Followed by:

mvn clean compile

For full details of all options, see the plugin README.


The generated models use commonly used Swagger v2 annotations like @ApiModelProperty. A user may add Swagger v3 annotations:


But this will not work. This dependency is not binary compatible with Swagger v2 annotations. The resulting code will fail to compile.

As alternative instead use the following dependency:



This gradle plugin offers a declarative DSL via extensions (these are Gradle project extensions). These map almost fully 1:1 with the options you’d pass to the CLI or Maven plugin. The plugin maps the extensions to a task of the same name to provide a clean API. If you’re interested in the extension/task mapping concept from a high-level, you can check out Gradle’s docs.

To include in your project, add the following to build.gradle:

buildscript {
repositories {
maven { url "" }
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:5.0.0"

apply plugin: 'org.openapi.generator'

This gives access to the following tasks:

openApiGenerateGenerate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents.
openApiGeneratorsLists generators available via Open API Generators.
openApiMetaGenerates a new generator to be consumed via Open API Generator.
openApiValidateValidates an Open API 2.0 or 3.x specification document.

The plugin implements the above tasks as project extensions of the same name. If you’d like to declare these tasks as dependencies to other tasks (using dependsOn), you’ll need a task reference. e.g.:

compileJava.dependsOn tasks.openApiGenerate

For full details of all options, see the plugin README.


An example task for generating a kotlin client:

openApiGenerate {
generatorName = "kotlin"
inputSpec = "$rootDir/specs/petstore-v3.0.yaml".toString()
outputDir = "$buildDir/generated".toString()
apiPackage = "org.openapi.example.api"
invokerPackage = "org.openapi.example.invoker"
modelPackage = "org.openapi.example.model"
configOptions = [
dateLibrary: "java8"