OpenAPITools / OpenAPITools/openapi-generator

[REQ] Add the ability to redefine the folder with the generated files which have `TemplateFileType != SupportingFiles`

Open
#18,057 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

Hello dear colleagues!

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

There is a file TemplateDefinition.java which refers to the mustache templates from openapitools.json. This class have a folder field, which according to the documentation adds a folder in the target output directory where the target file should be placed. And it seems that the folder field should work, but in the file DefaultGenerator.java this rule with folder field applies only to templates with TemplateFileType=SupportingFiles

Describe the solution you'd like

We can add the ability to change the target directory based on the folder property from openapitools.json is not only for the SupportingFiles type

Describe alternatives you've considered

_

Additional context

For example, this config (part of openapitools.json) will generate file in folder models/all.ts

"models_all.mustache": {
    "folder": "models",
    "destinationFilename": "all.ts"
}

Because it's have a templateType=SupportingFiles

But this config will generate all models files in root of target dir

"validators.mustache": {
    "destinationFilename": ".ts",
    "folder": "models",
    "templateType": "Model"
}

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 with TemplateDefinition.java and DefaultGenerator.java, then inspect the relevant template entries in openapitools.json. Compare how the folder property is applied for SupportingFiles versus Model templates. Done means a non-SupportingFiles template such as validators.mustache is generated under its configured folder, while the existing SupportingFiles behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.