How do I skip generation of Controller classes with Gradle's org.openapi.generator plugin?

232 views Asked by At

I'm using OpenAPI specs for generation of API interfaces and models. As a result in build folder I get e.g. interface ValidateApi and its implementation ValidateApiController.

Is there a property for org.openapi.generator plugin (version 7.0.1) that would allow me generate only model and interfaces?

This is my config:

openApiGenerate {
    generatorName = "spring"
    inputSpec = "$projectDir/src/main/api/${spec}".toString()
    outputDir = "$projectDir/build"
    apiPackage = "com.smth.api"
    modelPackage = "com.smth.model"
    configOptions.set([
            useOneOfInterfaces                  : "false",
            hideGenerationTimestamp             : "true",
            skipIfSpecIsUnchanged               : "true",
            additionalModelTypeAnnotations      : "@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor",
            generatedConstructorWithRequiredArgs: "false",
            useTags                             : "true"
    ])
    validateSpec = false
    globalProperties.set([
            modelDocs      : "false",
            models         : "",
            apis           : "",
            supportingFiles: "ApiUtil.java"
    ])
    typeMappings = [
            "date"   : "OffsetDateTime",
            "instant": "LocalDate"
    ]
    importMappings = [
            OffsetDateTime: "java.time.OffsetDateTime",
            LocalDate     : "java.time.LocalDate"
    ]
}
1

There are 1 answers

1
Sergey Tsypanov On BEST ANSWER

Finally I've solved it by adding interfaceOnly : "true" to configOptions.