swagger-api / swagger-api/swagger-codegen
[Spring] config 'templateDirectory' for custom mustache files is not working for language Spring for file api.mustache
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
with codegen maven plugin version 3.0.29 the configuration parameter 'templateDirectory' for custom mustache files is not working for language 'Spring' for file api.mustache.
However the same works with pojo.mustache in the specified templateDirectory.
OS: windows 10
It throws a FileNotFoundException in URLTemplateLoader of handlebars-4.1.2.jar. Cause: it prefixes the correct resolved absolute path with "/handlebars/JavaSpring/
e.g.
Caused by: java.io.FileNotFoundException: /handlebars/JavaSpring/C:/Users/.../templates/api.mustache
Swagger-codegen version
3.0.29
Swagger declaration file content or url
plugin configuration
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.29</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
/src/main/resources/specification.yaml
</inputSpec>
<language>spring</language>
<apiPackage>org.myproject.gen.api</apiPackage>
<modelPackage>org.myproject.gen.model</modelPackage>
<generateModels>false</generateModels>
<configOptions>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
</configOptions>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
<supportingFilesToGenerate>
HomeController.java,SwaggerUiConfiguration.java
</supportingFilesToGenerate>
<templateDirectory>src/main/resources/templates
</templateDirectory>
</configuration>
</execution>
</executions>
</plugin>
Related issues/PRs
similar issues:
https://github.com/swagger-api/swagger-codegen/issues/8132
https://github.com/swagger-api/swagger-codegen/issues/8132
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
Start with the Spring generator's handling of api.mustache and the handlebars 4.1.2 URLTemplateLoader path shown in the report; compare it with the working pojo.mustache lookup. Reproduce using the Maven plugin configuration and templateDirectory on Windows, then verify that api.mustache loads from the configured directory without the malformed /handlebars/JavaSpring/ prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- handlebars, java, spring
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100