Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"?

like image 508
Yuriy D Avatar asked Aug 13 '26 00:08

Yuriy D


1 Answers

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

like image 106
Martin Hauner Avatar answered Aug 14 '26 16:08

Martin Hauner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!