Openapi 代码生成器 maven 插件标签详细信息
Posted
技术标签:
【中文标题】Openapi 代码生成器 maven 插件标签详细信息【英文标题】:Open Api code generator maven plug in tag details 【发布时间】:2021-12-04 18:26:56 【问题描述】:下面是我打开的api代码gen maven插件
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.2.0</version>
<executions>
<execution>
<id>server</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<skipValidateSpec>true</skipValidateSpec>
<inputSpec>$project.basedir/src/main/resources/games.yaml</inputSpec>
<generatorName>spring</generatorName>
<library>spring-boot</library>
<generateSupportingFiles>false</generateSupportingFiles>
<output>$project.build.directory/generated-sources</output>
<apiPackage>com.tintin.api</apiPackage>
<modelPackage>com.tintin.model</modelPackage>
<configOptions>
<supportingFilesToGenrate>ApiUtil.java</supportingFilesToGenrate>
<interfaceOnly>true</interfaceOnly>
<delegatePattern>true</delegatePattern>
<dateLibrary>java8</dateLibrary>
<skipDefaultInterface>true</skipDefaultInterface>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
configuration 和 configOption 标签有什么区别。哪些选项放置在哪些标签内?
【问题讨论】:
【参考方案1】:<configuration>
元素旨在为您的插件提供配置,即在您的情况下为 org.openapitools:openapi-generator-maven-plugin:x.y.z
。
<configuration>
元素是一个标准插件标签,旨在将插件配置封装为一个整体。它是一个通用元素,可以承载任何形状的任何子元素,并且对所有插件都是通用的。
另一方面,<configOptions>
是一个插件,即org.openapitools:openapi-generator-maven-plugin:x.y.z
,它声明特定于插件自身的配置属性的特定元素。
这是一个非标准标签,必须映射到插件XXXMojo.java
类型中的特定字段。
Here you can see the mapping:
public class CodeGenMojo extends AbstractMojo
// other properties
/**
* A map of language-specific parameters as passed with the -c option to the command line
*/
@Parameter(name = "configOptions")
private Map<?, ?> configOptions;
// ...
【讨论】:
以上是关于Openapi 代码生成器 maven 插件标签详细信息的主要内容,如果未能解决你的问题,请参考以下文章
是否可以使用 openapi-generator maven 插件在现有的 maven 项目中创建 Java 客户端?
生成 Spring 代码时如何将 OpenAPI“oneOf”属性与 openapi-generator-maven-plugin 一起使用