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>
相关推荐
jvstar2 小时前
JAVA面试题和答案
java
9坐会得自创2 小时前
使用marked将markdown渲染成HTML的基本操作
java·前端·html
Hello.Reader2 小时前
Flink ML 线性 SVM(Linear SVC)入门输入输出列、训练参数与 Java 示例解读
java·支持向量机·flink
oioihoii2 小时前
C++数据竞争与无锁编程
java·开发语言·c++
最贪吃的虎2 小时前
什么是开源?小白如何快速学会开源协作流程并参与项目
java·前端·后端·开源
资生算法程序员_畅想家_剑魔2 小时前
Java常见技术分享-16-多线程安全-并发编程的核心问题
java·开发语言
We....2 小时前
Java SPI 机制
java·开发语言
海南java第二人3 小时前
Java无锁并发编程:volatile+CAS原子类深度解析
java·cas·volatile
毕设源码-邱学长3 小时前
【开题答辩全过程】以 人才培养方案调查系统为例,包含答辩的问题和答案
java·eclipse