OpenAPITools使用——FAQ

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>
相关推荐
zrc00700712 分钟前
steam无法登录 steam错误 登录时出现错误。请稍后再试。解决办法 steam无法登录解决办法 湖南地区steam DNS问题解决办法
windows·经验分享·游戏·缓存·游戏程序·创业创新·玩游戏
SL_staff24 分钟前
制造订单交付闭环实践:用跨部门计划模板解决缺料-停机-返工三角死循环
java·开源·产品
device_Any27 分钟前
接口文档写着三个字段,接口返回了五个
android·java·linux
CCblandy30 分钟前
缓存淘汰实测:一次全表扫描把 LRU 命中率从 46% 打到 38%,W-TinyLFU 守住 50% 却贵 11 倍
后端·python·缓存·性能优化·架构
kingx331 分钟前
Bugku Reverse 与 Android 题解总集:APK / native / PE / IPA
android·逆向·ctf·bugku
Wang's Blog33 分钟前
Java 项目实战: 交友项目 - 小视频模块实战:访客记录、FastDFS 存储与 SpringCache 缓存
java·缓存·交友
大尚来也40 分钟前
PHP 内存溢出常见原因与优化排查步骤
android
香蕉大香蕉(06敬畏市场)43 分钟前
MySQL 单点详解(09)
java·数据库·mysql·面试·八股·大厂实习
吹什么轩1 小时前
constexpr 完全指南:从 const 的两种含义,到编译期计算的四次演进
java·前端·javascript
她的男孩2 小时前
租户 A 的验证码,却用了租户 B 的 AccessKey:Forge Admin 修跨租户短信串发
java·spring boot·saas