-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Handlebars template engine doesn't generate SupportingFiles properly #5320
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Thanks for reporting this. I know some people are using handlebars, but I guess only for model/api generation and not supporting files. I've opened #5364 to resolve this. I've tested it against the templates in your fork and everything but |
Thanks Had a quick review of code in PR and it looks good. Will look into details of the build.bat issue you saw |
Had the chance to run the new code in PR and it works fine for generating code for supporting files. I had no issue with the build.bat file it self, though found 2 issues where changing from -last in mustache template to @last to handlebars template doesn't produce the same behavior which is causing build fails with template from my repo. (Authentication/ApiAuthentication.handlebars & Startup.handlebars) Need to look into why the last item statement doesn't work the same way and how restructuring of those template parts should be done in order to make it work |
@lindgrenfredrik looks like you have incorrect syntax for Try changing from:
To:
And change things like this:
to:
I tested this locally and seems to work. I'm not familiar with the shorter syntaxes you have or where they come from. You can see the helpers available in jknack handlebars.java here: https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/helper/ConditionalHelpers.java |
I've been mainly looking at info on swagger-codegen page for which statements that need updating between mustache and handebars. This since both seem to use jknack for handlebars and didn't see any bad effects when using those with swagger codegen Will update templates I have with above changes to make them work same way as current mustache templates |
Tried to change template to use the ones mentioned above related to last statements @jimschubert did you try with other input file when you got it to work ? For some reason I now get a issue with \ characters in build.bat file that I for some reason didn't get when I tested it last week |
Bug Report Checklist
Any spec, any language using defaultGenerator that has supporting Files
Issue related to Template engine and not schema
945ea14 from GIT
Searched for Handlebars, found Switching template system from Mustache to Handlebars (or something else) #510
Not match for specific issue but understand that Handlebars suppport may not be fully in place
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?
openapi-generator version
945ea14
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 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
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?
The text was updated successfully, but these errors were encountered: