OpenAPITools / OpenAPITools/openapi-generator

[REQ] Allow user to add custom mustache template for adding/generating user specific code

Open
#3,507 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Problem

There is no provision to add custom logic or code other than modifying the existing mustache files. Users might want to add additional logic by creating their own mustache file, which might need a provision from the generator to support it.

This could be an optional feature but will generally useful to make custom template code generation to suit the needs of users generating the client whose has their own specific requirements.

proposed solution

The possible solution would be to give user provision to add his own custom template (.mustache) file and which will be processed while generating the client. may be from the generation command as the command line args or additional-properties key

Ex:
java -jar openapi-generator-cli.jar generate --input-spec https://..../../reference.json --generator-name r --output OutFolder --template-dir Utilities/templates --additional-properties customTemplate=custom.mustache

In the above command i have passed in custom.mustache as additional property with the key name as customTemplate, which might generate a custom.R (for R langauge client) file.

need suggestions

like to have discussion if there is a better way or approach of adding/implementing this keeping other language generation process in consideration.
@wing328

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the generate command's --template-dir and --additional-properties inputs, then compare how templates are processed across generators. No files or tests are named; done would require an agreed design and support for an optional custom .mustache file that can produce a custom R client file without disrupting other language generators.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, r
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.