swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[Spring] config 'templateDirectory' for custom mustache files is not working for language Spring for file api.mustache

Open JohannesProbst opened this issue 5 years ago • 1 comments

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

JohannesProbst avatar Oct 18 '21 08:10 JohannesProbst

I am also experiencing the same issue.

md1guy avatar Oct 22 '21 13:10 md1guy