Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger-codegen-cli-3.0.2 customizing html mustache templates #8964

Closed
navaneethaKolichelma opened this issue Nov 30, 2018 · 4 comments
Closed
Assignees
Milestone

Comments

@navaneethaKolichelma
Copy link

navaneethaKolichelma commented Nov 30, 2018

Description

Am new to swagger codegen and I have downloaded swagger-codegen-cli-3.0.2.jar and would like to customize the html output using customized mustache templates and downloaded the templates from swagger-codegen-generators

I have tried customizing the mustache template for swagger-codegen 2.3.1 and this worked.

Swagger-codegen version

swagger-codegen-cli-3.0.2

Swagger declaration file content or url
Command line used for generation

java -jar swagger-codegen-cli-3.0.2.jar generate -i swagger.json -l html -o . -t htmlDocs --template-engine 'mustache'

Steps to reproduce

java -jar swagger-codegen-cli-3.0.2.jar generate -i swagger.json -l html -o . -t htmlDocs --template-engine 'handlebars'
Build is not success
Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
templateFile: index.mustache
folder:
destinationFilename: index.html

When i execute without custom templates
java -jar swagger-codegen-cli-3.0.2.jar generate -i swagger.json -l html -o .
Build is successful and I can applying the defaault templates
13:45:12.679 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Building AST
13:45:12.724 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Applying Mustache spec
13:45:12.730 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Creating templates
13:45:12.767 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - About to parse: /handlebars/htmlDocs/style.css.mustache

But when I have executed as
java -jar swagger-codegen-cli-3.0.2.jar generate -i swagger.json -l html -o . -t htmlDocs --template-engine 'mustache'

Build is successful but The generated html is not as per customized mustache files

Related issues/PRs
Suggest a fix/enhancement

Please let me know if I am missing anything or how to use customized mustache or handlebars

@HugoMario
Copy link
Contributor

hello @navaneethaKolichelma i already added a PR fixing this issue, can you please verify when you have a chance?

Going to close it for now, but we can open it if you find something wrong.

@HugoMario HugoMario added this to the v3.0.4 milestone Dec 12, 2018
@HugoMario HugoMario self-assigned this Dec 12, 2018
@navaneethaKolichelma
Copy link
Author

Hi @HugoMario I have tried with latest swagger-codegen-cli-3.0.3.jar still facing the issue

java -jar swagger-codegen-cli-3.0.3.jar generate -i swagger.json -l html -t htmlDocs --template-version handlebars

Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
templateFile: index.mustache
folder:
destinationFilename: index.html
'
at io.swagger.codegen.v3.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:604)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:726)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:342)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: handlebars/htmlDocs/index.mustache
at com.github.jknack.handlebars.io.URLTemplateLoader.sourceAt(URLTemplateLoader.java:70)
at com.github.jknack.handlebars.Handlebars.compile(Handlebars.java:357)
at com.github.jknack.handlebars.Handlebars.compile(Handlebars.java:343)
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.generateSupportingFiles(DefaultGenerator.java:575)
... 3 more

java -jar swagger-codegen-cli-3.0.3.jar generate -i swagger.json -l html -t htmlDocs/ --template-version 1.0.0 --template-engine mustache

This worked but no change in HTML output

@HugoMario
Copy link
Contributor

@navaneethaKolichelma
can you please try with swagger-codegen-cli-3.0.4-20181212.141209-11.jar file and check if issue is still present?

@navaneethaKolichelma
Copy link
Author

@HugoMario

Handlebars and Mustache templates are working fine. Thank you for your support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants