[BUG] Handlebars template engine doesn't generate SupportingFiles properly
Created by: lindgrenfredrik
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? Any spec, any language using defaultGenerator that has supporting Files -
Have you validated the input using an OpenAPI validator (example)? Issue related to Template engine and not schema -
What's the version of OpenAPI Generator used? 945ea14b from GIT -
Have you search for related issues/PRs? Searched for Handlebars, found https://github.com/OpenAPITools/openapi-generator/issues/510 Not match for specific issue but understand that Handlebars suppport may not be fully in place -
What's the actual output vs expected output? Actual: Supporting files don't get compiled with template variables. Expected: Supporting files get compiled with template
Description
Have existing Templates for Handlebars that are used together with Swagger codegen and looking to migrate to openapi codegen instead
In generateSupportingFiles in DefaultGenerator.java it looks if files end with correct template extension before compiling them as templates otherwise just writing them as files. This works fine when mustache files registered for the different languages end with correct mustache but when switching engine it expects handlebars extension which isn't whats registered by "language" generator The name conversion is done later in current setup (that is why it works for i.e. model files), which never gets called for Supporting files.
Any ideas on how to solve this properly?
- Allow mustache extension for any template engine?
- Convert names earlier?
-
- Register template files in some other manner to append correct ending?
- Run compile for all supporting files regardless of extension?
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
generate -g aspnetcore -o tmp -i pet2.json -e handlebars -t aspnetcore3/2.1/
pet2.json is petstore swagger definition update to 2.0 format found here https://petstore.swagger.io/v2/swagger.json
templates for handlebars is existing mustache ones found in openapi repo but update for handlebars style (also available in my fork atm https://github.com/OpenAPITools/openapi-generator/compare/master...lindgrenfredrik:aspnetcore_handlebarsdiff-bd1652e990ffe227072a5c8908fd3054)
Steps to reproduce
run generate command above and check output in supporting files
Related issues/PRs
Non found
Suggest a fix
My temporary workaround is to allow mustache named targets to pass into compile section https://github.com/OpenAPITools/openapi-generator/compare/master...lindgrenfredrik:aspnetcore_handlebarsdiff-bd1652e990ffe227072a5c8908fd3054
Don't feel that this is the correct solution to the problem
So any ideas on how to solve this properly?
- Allow mustache extension for any template engine?
- Convert names earlier?
-
- Register template files in some other manner to append correct ending?
- Run compile for all supporting files regardless of extension?