gpt4 book ai didi

java - 使用 swagger codegen 插件通过多个 yaml 文件生成代码

转载 作者:行者123 更新时间:2023-12-02 09:55:44 24 4
gpt4 key购买 nike

我有几个 swagger 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)

有什么想法吗?

最佳答案

通过使用多次执行解决了我的问题,如下所示:

         <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>

关于java - 使用 swagger codegen 插件通过多个 yaml 文件生成代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56024850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com