Swadeep Mohanty
Swadeep Mohanty

Reputation: 289

openApiGenerate plugin in gradle project not generating source code

Following is my build.gradle configuration:

plugins {
    id 'java'
    id 'maven-publish'
    id 'org.springframework.boot' version '2.3.9.RELEASE'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id "org.openapi.generator" version "5.1.0"
}
repositories {
    mavenCentral()
}
dependencies {
    implementation 'io.springfox:springfox-swagger2:2.9.2'
    implementation 'io.springfox:springfox-swagger-ui:2.9.2'
    implementation 'io.springfox:springfox-bean-validators:2.9.2'
    implementation 'org.openapitools:jackson-databind-nullable:0.2.0'
}
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

openApiGenerate   {
    generatorName.set("spring")
    inputSpec.set("$rootDir/specs/swagger.json")
    outputDir.set("$buildDir/openapi-java-client")
    apiPackage.set("com.test.controllers")
    modelPackage.set("com.test.models")
    configOptions.put("dateLibrary", "java8")
}

sourceSets  {
    main {
        java {
            srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
        }
    }
}

When I am running this project with gradle build build is successful but, it's not generating source code from swagger.json file, could anyone suggest anything?

Upvotes: 1

Views: 4343

Answers (1)

Swadeep Mohanty
Swadeep Mohanty

Reputation: 289

I was doing some misconfiguration. Now its resolved with the following setup:

openApiGenerate   {
    generatorName = "spring"
    inputSpec = "$rootDir/spec/swagger.json".toString()
    outputDir = "$buildDir/generate-sources".toString()
    invokerPackage ="com.test"
    apiPackage = "com.test.controllers"
    modelPackage = "com.test.models"
    configOptions = [
            dateLibrary: "java8"
    ]
}
sourceSets  {
    main {
        java {
            srcDir(files("${openApiGenerate.outputDir.get()}/src/main"))
        }
    }
}

Upvotes: 1

Related Questions