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
  • #14633
Closed
Open
Issue created Feb 06, 2023 by Administrator@rootContributor

[REQ] Please add `endsWith` helper for handlebars templates

Created by: averche

Is your feature request related to a problem? Please describe.

I would like to conditionally generate code using handlebars templates for tags ending with a specific value.

Today, the openapi-generator supports startsWith but not the equivalent endsWith helper function:

https://github.com/OpenAPITools/openapi-generator/blob/d90bdcbec712130d157cd6331bcbbf2e093df8d3/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/handlebars/StringHelpers.java#L12-L65

Describe the solution you'd like

Support for a helper endsWith that acts just like the startsWith but for suffixes would be ideal:

     {{#endsWith myTag "my-suffix"}}
        yes
     {{else}}
        no
     {{/endsWith}}

Describe alternatives you've considered

I've tried using an approximate solution of {{#neq myTag (cut myTag "my-suffix")}} in my handlebars templates. Unfortunately this doesn't work as expected (it always returns true).

Assignee
Assign to
Time tracking