OpenAPITools / OpenAPITools/openapi-generator
[REQ] Allow usage of custom TemplateTypes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Hello !
I'm currently playing around a bit with the generation of a spring-boot web service from the petstore template to get more confident with openAPI generator in order to use it in a project, and here is my problem : I want to generate services from a .mustache I am working on, but there are only 7 TemplateTypes (API, APITests, APIDocs, Model, ModelTests, ModelDocs and SupportingFiles) that I can use through the 6 HashMaps corresponding (apiTemplateFiles, modelTemplateFiles, apiTestTemplateFiles, modelTestTemplateFiles, apiDocTemplateFiles, modelDocTemplateFiles) and none of them is appropriate.
Describe alternatives you've considered
A solution I thought could work is to choose APIDocs or APITests instead and just change the extension to Service.java, but the problem is that when I do that, the files are generated in a folder I don't seem to be able to choose, and the suffix "Api" is used even thought I didn't ask for it.
apiDocTemplateFiles.put(
"service.mustache",
"Service.sample");

Describe the solution you'd like
I think it would be a great addition if we were able to :
- Remove the "Api" suffix of generated classes
- Create our own TemplateType so we can generate more than just Api and Model if we want
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Spring Boot generator's TemplateTypes and the six template-file HashMaps used for the petstore template. Compare how apiDocTemplateFiles handles service.mustache with the requested custom type, output folder, and class suffix behavior. Done means custom TemplateTypes can be configured and generated files use the requested name and location without an unwanted Api suffix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100