Eddy
Eddy

Reputation: 1832

Gradle configuration for OpenAPI Generator

When using OpenAPI generator with Gradle, I would expect to emit the gendered sources to the standard directory used by other source generator plugins. Something like the Maven generated-sources.

So far I haven't been able to do so, particularly to limit the generation to Java source classes instead of a whole “archetype project”.

It seems that the OpenAPI Gradle plugin workflow isn't thought out the same as the Maven one.

Is there a configuration flag to omit generation of all non-java code and to do so in an “generated sources” folder such as /out/production/generated/?

Upvotes: 6

Views: 7751

Answers (1)

Mark
Mark

Reputation: 611

In case this is of help to anyone, I have built this skeleton of a Gradle and OpenAPI Generator project which generates API and model files directly into the project source file hierarchy.

It uses the following configuration:

openApiGenerate {
    generatorName = "spring"
    inputSpec = "..."
    outputDir = "$projectDir"
    apiPackage = "..."
    modelPackage = "..."
    configOptions = [
            interfaceOnly: "true",
            openApiNullable: "false",
            skipDefaultInterface: "true"
    ]
    globalProperties = [
            apis: "",
            models: ""
    ]
}

The example is here.

Upvotes: 9

Related Questions