Cli generator name option, replaces 'language' options in CLI and Maven Plugin#57
Conversation
The language option (--lang and -l in CLI, language in maven plugin) has drifted from the original intention of defining a top-level language implementation with variance on library. Generators began to encode generator type into language (e.g. erlang-client), reused language as framework-only (e.g. scalatra), or embedded language and framework (e.g. typescript-angular). With the 3.0.0 release of openapi-generator, we've moved to a standardization of these names, which means they no longer fit into the singular concept of a "language". We've discussed plans to provide a better user experience around the CLI, breaking apart the generator lookup into the variations that make up a generator: * language * type * framework * version? To do this, we must first deprecate language and warn users that what they're currently using (e.g. scalatra, typescript-angular) is being replaced by generatorName and that language may mean something else in a later version of the generator. For discussion, see OpenAPITools#39.
This example uses maven to generate via openapi codegen.
To execute:
mvn -f non-java.xml compile
Output location will be written to console.
|
question: I've left "language" as a required option for the CLI and maven plugin, but I'm wondering if we should go ahead and make both language and generatorName optional from the start? My reasoning for leaving it as required is that existing users will have this option anyway, so required/optional won't matter. However, now that I think about it, the warning message says to "use generatorName instead" and if a user does this and removes "language", they'll be told that language is required. Thoughts on going ahead and making both optional for now, and exposing an error manually if neither is set? I think this would ease both migration for existing users and onboarding for new users. |
|
This is nice, looks good to me! I think in the CLI there is also the option to output all available langs: Or something like that, this should be changed to There are also error message, when an invalid lang is selected, that says "available languages" => should be changed to "available generators" We also need to update our migration guide: I thought you wanted also to fail (have an error) if both "language" and "generator name" are set. Maybe I missed it from your code. If I remember well you also mention something about supporting old generator names during one release to ease the mig. Maybe we can add this map somewhere: And do a if |
I think both optional is good and error if both are set or if both are missing. |
|
@jmini thanks for doing such a thorough evaluation. I hadn't even considered the I'll make the improvements you've listed above. I think the I'll change the title of the PR to indicate it's a work in progress. Should we add a |
This removes CLI/maven plugin property requirements on language, to provide a better user experience with suggesting to use the new option. Errors on missing one of laguage/generatorName are exposed programmatically rather than via framework (airline/mojo). This also includes automatic mapping between "language" options which have been renamed, to ease the transition from the 2.4.0-SNAPSHOT and earlier users.
|
I've pushed some changes. I've deprecated the To list generators, I've created Last push also includes the mapping for the lang->generator-name renames as defined in the wiki. Once this is merged, we can update the wiki's mention of the |
| configurator.setGeneratorName(language); | ||
| } else { | ||
| LOGGER.error("A generator name (generatorName) is required."); | ||
| System.exit(1); |
There was a problem hiding this comment.
I think it is better to throw a MojoExecutionException instead of System exist (maven will terminate with an appropriate error message and can still do some other stuff)
There was a problem hiding this comment.
Thanks for catching this. I was just blindly copying what I added to the CLI code, and I can't believe I left System.exit here. 💃
|
|
||
| configurator.setLang(language); | ||
| // TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang. | ||
| if (isNotEmpty(generatorName)) { |
There was a problem hiding this comment.
Right after the if, I would add something:
if (isNotEmpty(language))
LOGGER.warn("The 'language' option is deprecated and was replaced by 'generatorName'. Both can not be set together");
throw new MojoExecutionException("Illegal configuration: 'language' and 'generatorName' can not be set both, remove 'language' from your configuration");
}
|
I have spotted 2 small changes in the MoJo. As indicated by @kenisteward on Gitter, I think it is I good idea to update the docs in this PR:
And in the |
|
@jmini all great feedback. Thanks! Do you think it's necessary to update the migration doc? It's not required to make the changes to the language switch in order to migrate, and it will want the user. I guess now that it's not required to change the language values, either, that it makes sense to list for consistency. |
|
@jimschubert: I have named it "migration guide" but this is also a "what are the main differences between Swagger-Codegen and OpenAPI Generator". After New maven coordinates section I would create 2 new sections:
In each new section I would summarize what have changed with one or two sentences. In New generators names section, I would add one sentence to say that OpenAPI Generator is tolerant with old names during one release. |
This also updates all README instances of -l/language options to use -g and generatorName.
…ge -l to -g option
|
@jmini Thanks again for the second pair of eyes. I had originally left all I was wondering, what determines that docs should exist under
Are we intending to move those under the folder to the wiki, or are we planning to deprecate the wiki in favor of source control docs? |
@wing328 extracted those files from the README with c32ef12 I just moved them into a Yes we we have planned to move more content into the repository (and remove them from the wiki). Multiple reasons for that:
I would say that we should migrate the content of the wiki into some files in the |
|
@jmini I fully agree with moving things to I think we should migrate everything from the wiki, as I find it confusing that there are multiple places for all of these details and I'm not easily able to do a search across the project from the wiki. I could fork the wiki into a subdirectory, but that wouldn't share a commit with this PR. |
|
The FAQ (wiki) that I originally created intends to be community driven FAQ as anyone can update it easily without a PR. (we did see contributions from the community to add more FAQs over time) The Q&A (mainly for the launch of openapi-generator) is not something I want people to update without approval/review as it represents our viewpoints. I agree it may confuse users and happy to see consolidations or other approaches to make our doc more useful and easily discoverable by our users. |
|
This discussion about " |
|
@jmini I think the Sorry if I didn't clarify the reasoning for my question previously. |
|
It is OK. Better more text to clarify than misunderstanding. I have updated my comment to say that the "docs vs wiki discussion" was moved to an other issue. It is great that you have updated the docs, and the Tell us when you consider this ready for test. |
|
@jmini this is ready to test. Sorry, I thought I had included that in my comment after the last push. |
jmini
left a comment
There was a problem hiding this comment.
This looks good to me, thank you a lot for this contribution!
|
@jimschubert can you solve the conflicts created by #124 so that we can merge this? During the merge, for each conflict inside the |
* master: (36 commits) jaxrs-cxf-cdi: fix outer enum (OpenAPITools#131) Move bash argv opt to end of ags line in scripts (OpenAPITools#124) Reduce CI logging (OpenAPITools#119) Download elm dependencies without prompting user. (OpenAPITools#118) [aspnetcore] Make the use of Swashbuckle optional (OpenAPITools#110) DefaultGenerator: fix NullPointerException (OpenAPITools#109) [Java] use html entities in javadoc of generated code (OpenAPITools#106) Update PULL_REQUEST_TEMPLATE.md [java] Enum in array of array (OpenAPITools#66) Rename datatype to dataType in CodegenProperty (OpenAPITools#69) update elm test to compile all elm files (OpenAPITools#95) Fix Petstore example for Elm (OpenAPITools#96) Update Docker documentation (OpenAPITools#97) CaseFormatLambda has been added, params for Rest-assured client has been refactored (OpenAPITools#91) Update integration.md [Clojure] Add util method to set the api-context globally (OpenAPITools#93) [JaxRS-Java] issue with implFolder on windows, and required fields generation for containers (OpenAPITools#88) Set parameters allowableValues dynamically (OpenAPITools#65) Meta: set version for "build-helper-maven-plugin" (OpenAPITools#89) Fix javadoc issues in "openapi-generator" module (OpenAPITools#84) ...
|
@jmini @wing328 I've fixed these merge conflicts. I've also added an exit code of 1 if the CLI is called without args, to indicate failure. I didn't test whether the airlift framework also does this on |
* Add generated samples for Helidon generators * Add generated server doc
fix(deps): update dependency rxjs to v6.6.3
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master.Description of the PR
The language option (--lang and -l in CLI, language in maven plugin) has
drifted from the original intention of defining a top-level language
implementation with variance on library. Generators began to encode
generator type into language (e.g. erlang-client), reused language as
framework-only (e.g. scalatra), or embedded language and framework (e.g.
typescript-angular).
With the 3.0.0 release of openapi-generator, we've moved to a
standardization of these names, which means they no longer fit into the
singular concept of a "language".
We've discussed plans to provide a better user experience around the
CLI, breaking apart the generator lookup into the variations that make
up a generator:
To do this, we must first deprecate language and warn users that what
they're currently using (e.g. scalatra, typescript-angular) is being
replaced by generatorName and that language may mean something else in a
later version of the generator.
For discussion, see #39.
Example usage of the maven plugin is explained in the commit message for e97736f. You must first run
mvn clean package installto stage the 3.0.0-SNAPSHOT from this branch into your local repository. Then, navigate tomodules/openapi-generator-maven-plugin/examplesand run:This will create an aspnetcore generated example under
target/generated-sources/.Warning messages introduced in this PR will look like (maven plugin output):