OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.99k stars 6.59k forks source link

[REQ] Provide templating authoring details in config-help or generate CLI command (or subcommands of generate) #1811

Open jimschubert opened 5 years ago

jimschubert commented 5 years ago

Is your feature request related to a problem? Please describe.

Yes. The barrier to entry for authoring templates or custom generators should be minimized.

Describe the solution you'd like

config-help should provide some options for displaying more than CLI-only generation flags.

Examples:

Describe alternatives you've considered

We could create a new CLI command, but that seems to add little value over one or more additional switches.

Additional context

I think any additional information should be hidden by default. That is, authoring and extension information shouldn't display when config-help is called for a generator without the additional switches. This is because some of our generators have a ton of options, and there's no need to crowd the terminal output.

The --supporting-files might be non-trivial because many generators conditionally add supporting files based on CLI options passed to the generator. I think we would need to update generators to "register" supporting files and associate them to the options which would lead to those files being generated.

The generated output could eventually be used to generate parts of our documentation (see #1770).

jimschubert commented 4 years ago

Vendor Extensions, Supporting Files may make more sense as a --dry-run option for the generate command or something similar. Features should be doable once #3614 is merged, and I envision either outputting a table to the generator doc page or creating an overall matrix like kangax's ES6 compat page (https://kangax.github.io/compat-table/es6/) or jwt.io' library option support display (https://jwt.io/).

I've output most of the details for modifying a generator via config help changes in #4941. These options (primitives, import/instantiation mapping) make sense as part of config-help because they are CLI options which may need to be modified to generate valid code, especially for specs users don't control.

Authoring details may make more sense as its own command. Authoring is a more advanced option which might require viewing or dumping template files for a given generator+library combination, with instructions for modifying the template. This could get hairy because some generators switch on options provided to the generate command to determine which files are added to the supporting files array.

I wonder if it may make more sense to create "subcommand" for the generate command. In airline, there aren't really subcommands, so it would require that we change generate to a group, with a default command of run. This would allow us to put the additional functionality here under commands like:

If we go the subcommand route, we could also consider having config-help as a subcommand. This might look like:

openapi-generator generate -g kotlin config-help

I don't know if airline supports group options, though.

jimschubert commented 4 years ago

See also #4976

jimschubert commented 4 years ago

Feature set documentation is available via #4941 and #5188 Standardization of vendor extensions is available via #5295 The --dry-run option as recommended in #4976 is available via #5332

Additional things I'd like to explore for this feature: