Hi, I'm struggling to configure the gradle plugin to generate only model.
I can't seem to pass any property at all in systemProperties. Is my syntax incorrect?
openApiGenerate {
generatorName = "java"
....
configOptions = [
dateLibrary: "java8",
useBeanValidation: true
]
systemProperties = [
modelDocs: "false"
]
}
gives:
Caused by: java.lang.IllegalStateException: System.getProperty(key) must not be null
at org.openapitools.generator.gradle.plugin.tasks.GenerateTask.doWork(GenerateTask.kt:350)
If sent as boolean it gives:
Caused by: java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
at org.openapitools.generator.gradle.plugin.tasks.GenerateTask.doWork(GenerateTask.kt:543)
How to send these flags via gradle plugin?
java -Dmodels -DmodelDocs=false -DmodelTests=false
org.openapitools:openapi-generator-gradle-plugin:3.1.0
@FatCash thanks for reporting the issue.
cc @jimschubert
Does not work with Kotlin DSL either:
openApiGenerate {
generatorName.set("java")
inputSpec.set("$projectDir/src/main/swagger/schema.json")
outputDir.set("$buildDir/generated")
modelPackage.set("a.b.c.model")
systemProperties.set(mapOf(
"models" to "true" // 鈫恏ere
))
}
there problem is in line of file org.openapitools.generator.gradle.plugin.tasks.GenerateTask.kt
355: originalEnvironmentVariables[key] = System.getProperty(key)
Map originalEnvironmentVariables could not contains nulls but getProperty returns null.
And for me it is unclear what we would like to achieve. If remember initial state and return this state after, then we need to remember not existing properties, store it in set and remove it after as well(not only change properties values from map)
@FatCash I've opened #764 to address this issue. Sorry it took a while- it's been a busy month.
THE fix (#764) by @jimschubert has been merged into master. Please give it a try using the SNAPSHOT version, docker image or building the project locally.
Thank you @jimschubert and @wing328
I confirm that jims latest commit works for gradle. This is the syntax to generate models only:
systemProperties = [
modelDocs: "false",
models: ""
]
models: "true" does not work because it thinks thats a model name. Can live with that!
I am getting error when I try a to generate a (java reactive webclient) client stub using gradle plugin I am generating in a subflolder of a parent folder . I submitted https://github.com/OpenAPITools/openapi-generator/issues/3467
Basically, if I make changes in like below:
systemProperties = [
modelDocs: "false",
apis: "",
supportingFiles:""
]
I am expecting apis and supporting files for client to be generated which it does but only for first time but it also generates settings.gradle along with it which gives error if you run task next time as it has entry with a defualt root name rootProject.name = "openapi-java-client"
@vmisra2018 your linked issue doesn't seem to have anything to do with systemProperties being non-functional. Can you clarify why you've commented on this issue? If unrelated to this issue, let's keep the discussion in your open issue.