Looks like template directory option (-t | --template-dir ) is ignored in 4.1.0-SNAPSHOT. Template directory always defaults to embeded dir.
Following condition from DefaultCodegen.processOpts() evaluates to false even when -t option is provided, e.g: -t swagger/my-template.
if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR))
I have added a log message right at the end of DefaultCodegen.processOpts() method:
LOGGER.info("Template directory [templateDir={}]", this.templateDir());
Result message:
[main] INFO o.o.codegen.DefaultCodegen - [Template directory [templateDir=openapi-yaml]
BTW: Same issue is with Spring generator.
4.1.0-SNAPSHOT as of 14/July/2019.
java -jar "./modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate -i swagger/openapi.yml -g openapi-yaml -t swagger/my-template --additional-properties outputFile=swagger/swagger.yml
It looks like there is a quite difference in code gen configuration (e.g.: CodegenConfigurator.java) between 4.0.x and 4.1.0.
I do not know what is a direction in 4.1.x.
Thanks for reporting this. ~It looks like this may affect versions 4.0.2+.~ This only affected master.
GeneratorSettings and WorkflowSettings may need to push all properties with a corresponding CODEGEN_CONSTANTS into the additionalProperties map. I'll try to get a fix for this into master later today.
You are welcome.
BTW: This particular issue (with template directory) is not in 4.0.3.
I've filed #3385 to resolve the issue. Looks like templateDir was the only property I'd missed setting on additionalProperties.
Great, when merged, I will test it.
@MichalFoksa this has been merged into master. Feel free to reopen the ticket if there are other kinks that I've missed.
I believe it won't be necessary. :smiley:
@jimschubert it works. Thank you!
Most helpful comment
Thanks for reporting this. ~It looks like this may affect versions 4.0.2+.~ This only affected master.
GeneratorSettings and WorkflowSettings may need to push all properties with a corresponding CODEGEN_CONSTANTS into the additionalProperties map. I'll try to get a fix for this into master later today.