'OpenApi - CodeGeneration - Avoid/Modify Generation Of Version In Header Comments
We are generating java clients/models by the gradle plugin: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc
Generation works fine, and the header of the generated files locks like this, just an example:
Is there a way to change the version-string for the generation to a fix value without changing the whole gradle-version? Or even customize the generation of the file-header-comments somehow?
This would be very helpful to avoid too much commit-changes in the generated models each time, for files that are not affected by the current modifications.
/**
* Client classes generation (java)
*/
task generateApiCodeJavaClient(type: ext.GenerateTask) {
group = "openapi tools"
dependsOn "generateOpenApiDocs"
generatorName = "java"
inputSpec = openApiYamlPath
outputDir = project.ext.javaCodeDir
inputs.file inputSpec
outputs.dir outputDir
configOptions = [
dateLibrary: "java8",
java8: "true",
hideGenerationTimestamp: "true",
library: "resttemplate"
]
}
Any suggestions? Thanx.
Solution 1:[1]
Ok, it has nothing directly to do with the openapi-generator-gradle-plugin, rather than with schema definition. Modifying the version in io.swagger.v3.oas.annotations.info-Annotation fixed this issue.
There is also another way to modify the version text for the Swagger-Application-Start, but this did not work for me, maybe parameters are not 100% correct. See commented-out line with 'forkProperties'. If someone knows anything about this comments are welcome.
openApi {
// http://localhost:58427/openapi/api-docs.yaml
apiDocsUrl.set("http://localhost:$openApiPort/openapi/api-docs.yaml")
outputDir.set(file("$openApiYamlLocation"))
outputFileName.set("$openApiYamlFileName")
//forkProperties = "-Dspring-boot.run.arguments='--spring.application.version=$productWinVersion'"
waitTimeInSeconds.set(120)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


