Skip to content

Conversation

@PhilippHeuer
Copy link
Contributor

@PhilippHeuer PhilippHeuer commented Sep 18, 2021

The openapi-gradle generator plugin has a strict check on the engine param to only set the parameter if handlebars is set as value. Otherwise the parameter is ignored. This is currently blocking anyone from specifiying custom template engines (https://openapi-generator.tech/docs/templating/#custom-engines) when using the official gradle plugin.

This change will set the engine param to the user-provided value, even if it's not handlebars.

The engine param was initially added in: #5686

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

PhilippHeuer added a commit to twitch4j/nitro-codegen that referenced this pull request Sep 19, 2021
…use default javacodegen as base

current gradle plugin version is from mavenLocal, waiting for pr OpenAPITools/openapi-generator#10416 to be merged.
@wing328
Copy link
Member

wing328 commented Sep 21, 2021

This change will set the engine param to the user-provided value, even if it's not handlebars.

Thanks for the PR. What other values are allowed?

Shall we validate the input to only allow handlebars, mustache ?

@PhilippHeuer
Copy link
Contributor Author

This change will set the engine param to the user-provided value, even if it's not handlebars.

Thanks for the PR. What other values are allowed?

Shall we validate the input to only allow handlebars, mustache ?

When working with a custom engine (https://openapi-generator.tech/docs/templating/#custom-engines) - example https://github.com/twitch4j/nitro-codegen/blob/master/template-engine/src/main/java/com/github/twitch4j/codegen/engine/PebbleEngineAdapter.java#L26 - it's important that users can provide the custom identifier value (peb in the example), otherwise it's not possible to use custom template engine adapters with the gradle plugin.
Therefore any value can be valid, this depends on the identifiers used in custom template engine adapters - this makes value validation hard.

If users provide a invalid value than the openapi-generator will return this kind of error:

Exception in thread "main" java.lang.RuntimeException: Couldn't load template engine adapter my-custom-engine. Available options:
mustache
handlebars

Therefore i don't think we need this kind of validation in the gradle plugin, as we already get good error messages from the generator.

@wing328
Copy link
Member

wing328 commented Sep 22, 2021

@PhilippHeuer thanks for the PR and the explanation. Makes sense to me.

@wing328 wing328 merged commit 3b6b194 into OpenAPITools:master Sep 22, 2021
@PhilippHeuer PhilippHeuer deleted the fix/gradle-engine-custom branch September 22, 2021 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants