Can I define new mustache template variables in swagger-codegen?

Viewed 712

I have developed a rest-api client (in java) customised to the needs of my product. I wanted to generate tests using my rest api client using swagger-codegen modules based on yaml-file.

I have already extended DefaultCodegenConfig & even tried implementing the CodegenConfig interface to build my custom jar. I have customized the api.mustache and api_test.mustache files and passing them in the constructor and processOpts() method of my CustomCodeGen that extends DefaultCodegenConfig.

However, I want to use the custom/new mustache template variables that I have added in my customised api.mustache.

For e.g. if refer to standard api.mustache, the template variables it typically uses are

 - {{classname}} 
 - {{#operation}} 
 - {{#contents}} 
 - {{#parameters}} 

etc.

Now, I want to introduce a new template variable, let's say {{custom_param}}. Now I am not clear how do I integrate this new template variable with the implementation.

Looks like from this Mustache-Template-Variables published here, swagger-codegen does not allow adding new template-variables and perhaps we are restricted to only the variables mentioned on this page.

So, is there some way to make the new template variables work ?

1 Answers
Related