[BUG] [gradle] Tasks that inherit ValidateTask will fail if recommend is not assigned.
Created by: doyasu24
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
I am using the openapi-generator-gradle-plugin. I've noticed that the default value doesn't work well with ValidateTask. I tried the samples in this repository and the problem was reproduced.
Although recommend
has a default value, tasks that inherit ValidateTask will fail if recommend
is not assigned.
https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin#openapivalidate
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
// recommend = true
// recommend = false
}
openapi-generator version
I have tried with 4.3.0 and 4.3.1.
OpenAPI declaration file content or url
Command line used for generation
./gradlew validateGoodSpec
./gradlew -PopenApiGeneratorVersion=4.3.0 validateGoodSpec
./gradlew -PopenApiGeneratorVersion=4.3.1 validateGoodSpec
Steps to reproduce
I clone this repository and exec validateGoodSpec.
git clone git@github.com:OpenAPITools/openapi-generator.git
cd openapi-generator/modules/openapi-generator-gradle-plugin/samples/local-spec
./gradlew validateGoodSpec
> Task :validateGoodSpec FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':validateGoodSpec'.
> No value has been specified for this provider.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 895ms
1 actionable task: 1 executed
I have explicitly assigned true or false to recommend
.
Then the task was successful.
> Task :validateGoodSpec
Validating spec /****/openapi-generator/modules/openapi-generator-gradle-plugin/samples/local-spec/petstore-v3.0.yaml
Spec is valid.
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/4643 https://github.com/OpenAPITools/openapi-generator/pull/5183
Suggest a fix
I think it should be set default value before get
is called at https://github.com/OpenAPITools/openapi-generator/blob/5fe34fbd74e8078f7f3ee180bfb302ab2d0662d8/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt#L72