swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Add templated supporting files by config

Open cbornet opened this issue 10 years ago • 6 comments

It would be great to be able to add custom supporting files by config when using an alternate template dir Eg.

{
  "additionalSupportingFiles": {
    "myCustomClass.mustache": "src/main/java/com/company/myapp/myCustomClass.java"
 }
}

cbornet avatar Feb 08 '16 16:02 cbornet

@cbornet ... I have raised issue #2047. Are you suggesting the same? We are using config and for alternate template path we required to extend DefaultCodeGenerator.

sbelan avatar Feb 09 '16 05:02 sbelan

@cbornet do you mind sharing with me a bit more about your use case of adding additional files to be used by Codegen? Currently do you have any workaround for this limitation?

wing328 avatar Feb 18 '16 15:02 wing328

Of course. For instance I use a template to adapt the feign generator to Spring-Boot, generating automatically some beans for the apiclient and the apis that the user can then inject wherever he wants with Spring DI. With the current implementation, I cannot create new files so I have to put everything in ApiClient with nested classes. It would be easier and make the code more readable if I could create more classes.

cbornet avatar Feb 18 '16 15:02 cbornet

Here is my templated ApiClient for reference.

cbornet avatar Feb 18 '16 15:02 cbornet

Has this feature been added? This would be very useful!

Keyrat06 avatar Jul 24 '17 20:07 Keyrat06

PR: https://github.com/swagger-api/swagger-codegen/pull/6487/files

wing328 avatar Nov 29 '17 04:11 wing328