swagger-api / swagger-api/swagger-codegen
[iOS][Swift5] Can't find template files
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If I'll indicate a custom folder with template files for code generation, it will throw a file not found exception, more details bellow
Swagger-codegen version
3.0.26
Command line used for generation
swagger-codegen generate -i https://docs.helloreco.holiday/swagger/support.yaml -t handlebars -l swift5 -o TestOutput/
The handlebars is a folder located in /Users/username/Documents/project-ios/RecoSwaggerClient with this structure:
-- handlebars
-- swift5
-- model.mustache
-- ... other mustache files
Result after running the command in /Users/username/Documents/project-ios/RecoSwaggerClient
13:42:18.248 [Thread-0] INFO i.s.c.v.i.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
Exception in thread "Thread-0" java.lang.RuntimeException: Could not generate model 'ApiErrorResponse'
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:451)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:779)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:378)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.FileNotFoundException: /Users/username/Documents/project-ios/RecoSwaggerClient/handlebars/handlebars/swift5/model.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:52)
at io.swagger.codegen.v3.templates.HandlebarTemplateEngine.getRendered(HandlebarTemplateEngine.java:25)
at io.swagger.codegen.v3.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:795)
at io.swagger.codegen.v3.DefaultGenerator.generateModels(DefaultGenerator.java:438)
... 3 more
I had previously installed version 3.0.24 and all was working as expected, after updating to 3.0.24 I am having this error. It seems that it's trying to find the templates not directly in the indicated folder (from -t param).
As well if I'll indicate another folder for -t param, let's say templates, it seems to use default templates and ignore the ones from fodler.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported command with swagger-codegen 3.0.26 and compare it with 3.0.24. Start at DefaultGenerator.java and templates/HandlebarTemplateEngine.java, following the stack trace through Generate.run.java and URLTemplateLoader. Done means a custom -t directory is not duplicated in the lookup path and an alternate template directory is used instead of the defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- handlebars, swift
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100