FAQ
Q1:为什么生成的Controller接口中没有@Controller注解

建议排查配置项configOptions的useSpringController是否为true
xml
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<!--其他配置...-->
<configuration>
<!--其他配置...-->
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<useSpringController>false</useSpringController>
</configOptions>
</configuration>
</execution>
</executions>
Q2:服务端代码生成时如何防止pom文件被覆盖
可以配置openapiGeneratorIgnoreList为pom.xml防止覆盖
xml
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<!--其他配置...-->
<configuration>
<!--其他配置...-->
<openapiGeneratorIgnoreList>pom.xml</openapiGeneratorIgnoreList>
<configOptions>
<!--其他配置...-->
</configOptions>
</configuration>
</execution>
</executions>
Q3:客户端代码生成时禁用API文档生成
在客户端代码生成时同步生成了api接口文档,如何禁用?

建议排查配置项configuration的generateApiDocumentation是否为false。如何不想生成任何文档,建议将generateApiDocumentation,generateModelDocumentation都设置为false
generateApiDocumentation:是否生成 API 接口相关文档generateModelDocumentation:生成数据模型相关文档
xml
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<!--其他配置...-->
<configuration>
<!--其他配置...-->
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<configOptions>
<!--其他配置...-->
</configOptions>
</configuration>
</configuration>
</execution>
</executions>
Q4:客户端代码生成时禁用Gradle等生成
使用maven构建时,默认生成了gradle的配置文件

建议排查配置项configuration的generateSupportingFiles设置为false,但是需要自己手动补全一些文件如ApiClient等
xml
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<!--其他配置...-->
<configuration>
<!--其他配置...-->
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<!--其他配置...-->
</configOptions>
</configuration>
</configuration>
</execution>
</executions>