OpenAPITools使用——FAQ

FAQ

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

建议排查配置项configOptionsuseSpringController是否为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文件被覆盖

可以配置openapiGeneratorIgnoreListpom.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接口文档,如何禁用?

建议排查配置项configurationgenerateApiDocumentation是否为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的配置文件

建议排查配置项configurationgenerateSupportingFiles设置为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>
相关推荐
majingming1237 小时前
FUNCTION
java·前端·javascript
zopple7 小时前
常见的 Spring 项目目录结构
java·后端·spring
Chengbei118 小时前
Redis 图形化综合检测工具:redis_tools_GUI,一键探测 + 利用
数据库·redis·web安全·网络安全·缓存·系统安全
流星白龙8 小时前
【MySQL】7.MySQL基本查询(2)
android·mysql·adb
xuxie998 小时前
N11 ARM-irq
java·开发语言
cjy0001119 小时前
springboot的 nacos 配置获取不到导致启动失败及日志不输出问题
java·spring boot·后端
mldlds9 小时前
MySQL加减间隔时间函数DATE_ADD和DATE_SUB的详解
android·数据库·mysql
wefly20179 小时前
从使用到原理,深度解析m3u8live.cn—— 基于 HLS.js 的 M3U8 在线播放器实现
java·开发语言·前端·javascript·ecmascript·php·m3u8
zhenxin01229 小时前
Spring Boot实现定时任务
java
小江的记录本9 小时前
【事务】Spring Framework核心——事务管理:ACID特性、隔离级别、传播行为、@Transactional底层原理、失效场景
java·数据库·分布式·后端·sql·spring·面试