使用swagger codegen插件通过多个Yaml文件生成代码

时间:2019-05-07 14:27:30

标签: java maven swagger-codegen

我有几个摇摇欲坠的yaml文件,我想在编译时使用maven生成代码。

这是我的代码:

 <plugins>
        <plugin>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <version>2.3.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>${project.basedir}/src/main/resources/*.yaml</inputSpec>
                        <language>java</language>
                        <configOptions>
                            <sourceFolder>src/gen/java/main</sourceFolder>
                        </configOptions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

我正在尝试获取资源中所有的yaml文件作为输入:

<inputSpec>${project.basedir}/src/main/resources/*.yaml</inputSpec>

但是这不起作用,我遇到了这个错误:

failed to read resource listing
java.io.FileNotFoundException: C:\Projets\www\codegen\src\main\resources\*.yaml (La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte)

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我的问题通过使用以下多个执行方式得以解决:

         <plugin>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <version>2.4.5</version>
            <executions>
                <execution>
                    <id>a</id> .....
                </execution>
                <execution>
                    <id>b</id> .....
                </execution>
                <execution>
                    <id>c</id> .....
                </execution>
             </executions>
          </plugin>
相关问题