Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove ApiUtil.java from openApi geneate task with openapi-generator-gradle-plugin:4.3.0

I have am using openapi-generator-gradle-plugin:4.3.0 to generate the api and models from a openApi-generate.yaml file. I have set skipDefaultInterface: "true" in configOptions, the default implementation of interfaces is not generated and ApiUtil.java is not used anywhere. (The default implementations used ApiUtil.java)

What I want is to remove (disable the generation of) ApiUtil.java from generated_sources, as it is not used in code, and its default code is creating security-issues in pipeline as well.

What I have tried: I have tried adding different options::

  1. supportingFilesConstrainedTo = []
  2. supportingFiles = ""
  3. supportingFilesToGenerate = ""
  4. apiFilesConstrainedTo = []

But I haven't been able to remove this file from being generated. I went through this: OpenApi generation Customization, but looks like it is not applicable for the given version.

Current gradle buildscript looks as:

task generateTask(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = "spring"
    inputSpec = "$projectDir/src/main/resources/specs/openApi-generate.yaml"
    outputDir = "$buildDir/generated-sources"
    apiPackage = "com.example.openapi.api"
    modelPackage = "com.example.openapi.model"
    generateModelDocumentation = false
    generateApiDocumentation = false
    generateModelTests = false
    generateApiTests = false
    configOptions = [
        dateLibrary: "java8",
        interfaceOnly: "true",
        serializableModel: "true",
        skipDefaultInterface: "true"
    ]
}
like image 422
Harish Kumar Saini Avatar asked Jun 17 '26 11:06

Harish Kumar Saini


1 Answers

A bit late but always good to give a good answer.

You have to use the configOption skipDefaultInterface but you also need to set the property generateSupportingFiles to false (which is NOT one of the configOptions but goes directly under configuration)

like image 121
user3839936 Avatar answered Jun 19 '26 23:06

user3839936