Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5320
Closed
Open
Issue created Feb 14, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[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

945ea14b

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?
Assignee
Assign to
Time tracking