Skip to content

maven-codegen-plugin Access custom templates from jar  #10508

@tibors13

Description

@tibors13
Description

I have following situation

  • customCodegen as jar artifact
  • customized templates as part of the same jar (similar packaging like with (e.g. adaptedTemplate)
  • used customCodegen from swagger-codegen-maven-plugin
  • using copy depen -to extract templates to working directory

If I extract and copy adaptedTemplate directory to build path -> it works OK

Swagger-codegen version

3.0.21

Swagger declaration file content or url
Command line used for generation

swagger-codegen-maven-plugin

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Question: is it possible to load modified templates directly from jar file, similar to original swagger-generators ?
Customized codegen code works fine, just to unpack (in many poms is quite tedious :( )

I see problem in https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/config/CodegenConfigurator.java
at setTemplate expects local directory, or is there any workaround?
Would it be possible to specify jar file access to load modified templates?
( swagger.yml from jar works nice just as dependency in plugin, similar to custom codegen in customgenerator

  1. option would be to check local directory existence -> if not expect jar access
  2. other - define it alternate ways

(other problems would be to access them in Handlebar, but this I have probably solved, as I had modified HandlebarTemplateEngine search algorithm to access all 4 places, as it was in codegen v2.x )

Overwrite this configurator is neither not so easy, as created in swagger-coden-maven-plugin directly.
Thanks for any hints

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions