Skip to content

[REQ] Load templates from classpath #5136

@eicki

Description

@eicki

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

Currently the only way to overwrite embedded templates is to use the templateDir. If openapi generator is used in multiple projects that should share all the same customized templates you have to copy the templates to each project or to fork and adjust he generator project itself and adjust the embedded templates directly.

Describe the solution you'd like

Add a templateResourcePath option that if set defines a resource path in the classpath to look for templates files. If both templateDir and templateResourcePath is set, template files from templateDir should take precedence. By doing so you can define a company wide set of templates that overwrite the embedded templates but still allowing to overwrite templates on a per api basis.

Describe alternatives you've considered

Extending templateDir to allow a comma-separated list of directories and allowing Spring like "classpath:" prefix denoting paths that should be resolved via classloader. But I did not opt for this option because templateDir is already a File and not a String, so you would need to alter this and in the end it sounded a little bit too much. Thus I decided for a new option.

Additional context

Pull Request will follow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions