-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[BUG] Gradle Plugin - configOptions unclear / inconsistent #7479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's broke. Doesn't work |
@black-snow the options you're asking about are different from the example. The example from the gradle plugin that you've shared above is for kotlin which does not have an For Java, as for the reason why these exist in both locations is a little more of history from swagger-codegen than anything else. That tool was originally a CLI tool only, so all our generators have a All of our plugins and the CLI use the same "configurator" object which maps those CLI top-level properties and configOptions properties in the same way. For a generator like Java which duplicates those top-level CLI options as configOptions, you can apply them in either place. It's not clean and that's why I opened #2556. I've been slowly moving away from these, but we're also bound by existing users and our rule to not introduce breaking changes except for major releases (we've had only 1 major release since our fork's initial release). |
Thanks for your reply!
No, I can't. When I add any of the options to
I just copy-pasted the example from the linked docs - I didn't come up with this. I (try to) use it for java and of course my config looks a little different. This issue will probably resolve with #2556. |
@black-snow I don't understand this line:
Your comments seem to suggest that you're missing a major point. That is - To make this example concrete, in relation to the java generator you can compare the following configuration options:
These very clearly document "Config Options" for these different generators, and those documented keys are the only values acceptable in You can directly apply the following diff to this repo's master branch. This moves from kotlin configuration (as used in the gradle documentation) to a java generator (which again is the only one of these two the defines a diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle
index cb99b8838f..1be4c2d8e9 100644
--- a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle
+++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle
@@ -33,14 +33,14 @@ openApiValidate {
// Builds a Kotlin client by default.
openApiGenerate {
- generatorName = "kotlin"
+ generatorName = "java"
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
- outputDir = "$buildDir/kotlin".toString()
- apiPackage = "org.openapitools.example.api"
- invokerPackage = "org.openapitools.example.invoker"
- modelPackage = "org.openapitools.example.model"
+ outputDir = "$buildDir/java".toString()
configOptions = [
- dateLibrary: "java8"
+ dateLibrary: "java8",
+ invokerPackage: "org.openapitools.example.invoker",
+ modelPackage: "org.openapitools.example.model",
+ apiPackage: "org.openapitools.example.api"
]
globalProperties = [
modelDocs: "false" Run We use Gradle caching so you may not see the message about generation if you've already generated outputs and the generated files have not changed. You can verify the output of generated contents:
To your point about consistency, kotlin and java do have different As for the issues you're having with compilation, again I think you're trying to mix config options documented for the Java generator into the kotlin example and that's just not supported. I don't follow what's unclear about this but we're open to improving the docs to make it more clear if you have any recommendation on how to clarify. |
I'm not doing anything with kotlin, it's 100% java. All I did was picking the example from the docs. My config looks like openApiGenerate {
generatorName = "java"
library = "webclient"
verbose = true
validateSpec = true
skipValidateSpec = false
inputSpec = "$rootDir/src/main/resources/schema_oas3.yaml"
outputDir = "$rootDir/../api"
configOptions = [
dateLibrary: "java8",
openApiNullable: "true"
]
apiPackage = 'a.b.xyz.openapi'
modelPackage = 'a.b.xyz.openapi.model'
invokerPackage = 'a.b.xyz.openapi.client'
groupId = 'a.b'
id = 'xyz'
version = '0.1'
} My point was that it's not clear to me what goes inside |
@black-snow so the confusion is that the table listed as "Config Options" should go inside I think clarifying this at the top of these pages would be easy enough, if that is indeed where the confusion lies. |
Yup. It's initially just unclear that there's language specific stuff and general stuff and what goes where. Your issue about this should mostly fix this, I think. |
For those top-level tooling options, it looks like I'll need to deprecate with a warning at the very least through 5.1.0, possibly throughout all of 5.x. In the meantime, I've added a clarification documentation around the different types of properties. See https://openapi-generator.tech/docs/configuration |
Awesome. Thanks for your efforts. I'll close this specific issue then. |
Bug Report Checklist
x
Couldn't find a repo for the gradle plugin so I'm posting this here.
Description
The gradle plugin offers some configuration option. But it's not clear what has to go where. The docs have an example:
Why is
dateLibrary
nested insideconfigOptions
or regardingly, why isn't e.g.invokerPackage
withinconfigOptions
, too? Both are listed in the same table [1] [2] captioned "config options". So I'd expect all those settings to live withinconfigOptions
or none.openapi-generator version
4.x & 5.0.0-beta2
Suggest a fix
I didn't take a look at the other generators. Maybe I'm just blind and it's stated somewhere.
My first shot to fix this would be to unnest
configOptions
so that above example becomes:The text was updated successfully, but these errors were encountered: