OpenAPITools / OpenAPITools/openapi-generator
[REQ] Add an "overridesEmbedded" to Codegen Configs to Allow Extensions
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.
Currently, the CodegenConfigLoader just returns the first Config for a given name. This limits the ability for users to extend a provided code generator (the ServiceLoader as far as I can tell loads Services in arbitrary order).
Describe the solution you'd like
The name for this method could probably be more descriptive. The basic solution is this:
- Add a method
Boolean overridesEmbedded()to theCodegenConfig. - Add a method
String overridesDir()to theCodegenConfigwhich defines the root of the set of templates to overlay on top of theembedded-dir. - Update [AbstractGenerator.getFullTemplateFile] to check
overridesDirafter<template-folder>/*, but before<embedded-folder>/*which should avoid breaking changes for users of thetemplateDircommandline parameter. - Add a implementations in
DefaultCodegenConfig:
@Overrides
public Boolean overridesParent() {
return false;
}
@Overrides
public String overridesDir() {
return getTemplateDir();
}
- Update documentation to tell users who wish to customize existing Code Generators to override the
overridesParentandoverridesDirmethods in their custom code generator.
Describe alternatives you've considered
An alternative way to do this would be to add a priority field instead. This would let users extend other overrides by setting their priority above the defined priority of their override.
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 reading CodegenConfigLoader.java, AbstractGenerator.getFullTemplateFile, and DefaultCodegenConfig to trace configuration discovery and template lookup. Compare the proposed overridesEmbedded and overridesParent names, then check the surrounding documentation and tests. Done means custom code generators can overlay templates without changing existing templateDir behavior, with the documented configuration methods available.
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