Custom function in mustache files
Is it possible to call a custom function from one of the mustache templates as described in this doc? I looked through the code but couldn't find a way.
Yes, you can override the processApiMap or processModelMap functions and put a function in the maps, instead of strings.
OK thanks!
Damn it, that does not work because I need to have the function available when I write support files. Is there a way? Thanks
This is now supported nicely in develop_2.0. You can use a model factory to enable your own logic in the pojos and update the templates as needed. Please see https://github.com/swagger-api/swagger-codegen/pull/342
@wing328 @fehguy Is there a way to do this (custom template functions available in mustache) without having to modify the java code?
No, it's not possible right now. You can have your own templates with your own mustache conditionals.
Ok. And its' still valid that we would just modify the processModelMap to insert our own function? Do you think it's a common use case for people to override the java code to suite the generation to their codebase? It'd be nice if this were completely handled by templates, but I understand this is a limitation of mustache.
Yes, you can do that. We are collecting feedback on the next version of codegen, please chime in with your thoughts on this ticket:
https://github.com/swagger-api/swagger-codegen/issues/3950
And this:
https://github.com/swagger-api/swagger-codegen/issues/3948