Yuriy D
Yuriy D

Reputation: 105

openapi-generator gradle plugin output directory

I am using the openapi-generator Gradle plugin to generate model files from the open API schema. With these settings in build.gradle script everything seems ok:

openApiGenerate {
globalProperties = [
        apis: "false",
        modelDocs: "false",
        models: "Pet"
]
generatorName = "java"
generateModelTests = false
inputSpec = "$rootDir/src/main/resources/schema/my_schema.json".toString()
outputDir = "$rootDir".toString()
modelPackage = "org.openapi.example.model"
configOptions = [
        dateLibrary: "java8",
        serializationLibrary: "jackson",
        library: "jersey1"
]

}

And the result classes are generated in the proper package:

enter image description here

The problem is here - I don't need them in my sources, I need them only at compile stage. I want them to be generated in the build directory, to separate them from other logic. But when I am changing the output-dir to "$buildDir/generated".toString() this happens:

enter image description here

Is there a way to get rid of the wrong packages "src.main.java"?

Upvotes: 2

Views: 7553

Answers (1)

Martin Hauner
Martin Hauner

Reputation: 1733

You can set the "sourceFolder" option to an empty string.

configOptions = [
   sourceFolder: ""
]

This is an option of the generator not of the gradle plugin.

https://openapi-generator.tech/docs/generators/java

Upvotes: 8

Related Questions