Forum Discussion

OnkelTem's avatar
OnkelTem
Frequent Visitor
5 years ago

Cannot use custom templates with swagger-codegen-cli

I cannot generate nodejs-server using swagger-codegen-cli-v3 when passing any custom template. 

 

This is how I invoke swagger-codegen

java -jar swagger-codegen-cli.jar generate -i api.yaml -l nodejs-server -t mytemplates/ -o output/

And get the same error every time:

Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate api file for 'Auth'
        at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:579)
        at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:782)
        at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:360)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.FileNotFoundException: handlebars/nodejs/service.mustache
        at com.github.jknack.handlebars.io.URLTemplateLoader.sourceAt(URLTemplateLoader.java:70)
        at com.github.jknack.handlebars.Handlebars.compile(Handlebars.java:438)
        at com.github.jknack.handlebars.Handlebars.compile(Handlebars.java:419)
        at io.swagger.codegen.v3.templates.HandlebarTemplateEngine.getHandlebars(HandlebarTemplateEngine.java:48)
        at io.swagger.codegen.v3.templates.HandlebarTemplateEngine.getRendered(HandlebarTemplateEngine.java:24)
        at io.swagger.codegen.v3.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:795)
        at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:538)
        ... 3 more

More about this is here: https://github.com/swagger-api/swagger-codegen/issues/10107

 

Any ideas?