openapi generator maven plugin config parameter

这里写自定义目录标题

环境

我使用的版本如下:

xml 复制代码
<plugin>
	<groupId>org.openapitools</groupId>
	<artifactId>openapi-generator-maven-plugin</artifactId>
	<version>7.12.0</version>
</plugin>

常见配置

xml 复制代码
<plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${openapi-generator.version}</version> <!-- 使用最新稳定版本 -->
                <executions>
                    <execution>
                        <phase>generate-sources</phase> <!-- 绑定到 Maven 编译阶段 -->
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/api/api.yml</inputSpec> <!-- API 描述文件路径 -->
                            <generatorName>spring</generatorName> <!-- 生成 Spring 服务端代码 -->
                            <output>${project.build.directory}/generated-sources/openapi</output> <!-- 输出目录 -->
                            <apiPackage>com.example.demo.api.controller</apiPackage> <!-- 接口包名 -->
                            <modelPackage>com.example.demo.api.model</modelPackage> <!-- 模型类包名 -->
                            <configOptions>
                                <library>spring-boot</library>
                                <useSpringBoot3>true</useSpringBoot3>
                                <serializationLibrary>jackson</serializationLibrary>
                                <java8>true</java8> <!-- 标记生成代码兼容 Java 8 语法 -->
                                <dateLibrary>java8</dateLibrary> <!-- 使用 Java 8 的日期时间类型 -->
                                <useTags>true</useTags>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

常见参数及其配置说明

参数名 类型 配置说明
addCompileSourceRoot boolean Add the output directory to the project as a source root, so that the generated java types are compiled and included in the project artifact. Mutually exclusive with addTestCompileSourceRoot.
addTestCompileSourceRoot boolean Add the output directory to the project as a test source root, so that the generated java types are compiled only for the test classpath of the project. Mutually exclusive with addCompileSourceRoot.
additionalProperties java.util.List A map of additional properties that can be referenced by the mustache templates
apiNameSuffix java.lang.String Sets the suffix for api classes.
apiPackage java.lang.String The package to use for generated api objects/classes.
apisToGenerate java.lang.String A comma separated list of apis to generate. All apis is the default.
artifactId java.lang.String artifactId in generated pom.xml
artifactVersion java.lang.String artifact version in generated pom.xml
auth java.lang.String Adds authorization headers when fetching the swagger definitions remotely. " Pass in a URL-encoded string of name:header with a comma separating multiple values.
cleanupOutput boolean
collapsedSpec java.lang.String The path to the collapsed single-file representation of the OpenAPI spec.
configHelp boolean
configOptions java.util.Map A map of language-specific parameters as passed with the -c option to the command line
configurationFile java.lang.String Path to separate json configuration file.
dryRun boolean
enablePostProcessFile boolean To file post-processing hook
engine String The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
enumNameMappings java.util.List A map of enum names and the new names
environmentVariables java.util.Map
generateAliasAsModel boolean To generate alias (array, map) as model
generateApiDocumentation boolean Generate the api documentation
generateApiTests boolean Generate the api tests
generateApis boolean Generate the apis
generateModelDocumentation boolean Generate the model documentation
generateModelTests boolean Generate the model tests
generateModels boolean Generate the models
generateRecursiveDependentModels boolean Generate the models recursively if models should generate selectively (see modelsToGenerate) and all dependent models are to generate
generateSupportingFiles boolean Generate the supporting files
generatorName String The name of the generator to use.
gitHost String Git host, e.g. gitlab.com.
gitRepoId String Git repo ID, e.g. openapi-generator.
gitUserId String Git user ID, e.g. swagger-api.
globalProperties Map
groupId String groupId in generated pom.xml
httpUserAgent String Sets custom User-Agent header value
ignoreFileOverride String Sets an optional ignoreFileOverride path
importMappings List A map of classes and the import that should be used for that class
includeCollapsedSpecInArtifacts boolean Includes the collapsed spec in the Maven artifacts.
inlineSchemaNameMappings List A map of inline scheme names and the new names
inlineSchemaOptions List A map of inline scheme option and the value
inputSpec String Location of the OpenAPI spec, as URL or file.
inputSpecRootDirectory String Local root folder with spec files
instantiationTypes List A map of types and the types they should be instantiated as
invokerPackage String The package to use for the generated invoker objects
languageSpecificPrimitives List A map of additional language specific primitive types
library String Sets the library
logToStderr Boolean To write all log messages (not just errors) to STDOUT
mavenProject MavenProject The Maven project context.
mergedFileName String Name of the file that will contain all merged specs
modelNameMappings List A map of model names and the new names
modelNamePrefix String Sets the prefix for model enums and classes
modelNameSuffix String Sets the suffix for model enums and classes
modelPackage String The package to use for generated model objects/classes
modelsToGenerate String A comma separated list of models to generate. All models is the default.
mojo MojoExecution
nameMappings List A map of property names and the new names
openapiGeneratorIgnoreList List A list of openapi-generator-ignore entries
openapiNormalizer List A set of rules for OpenAPI normalizer
operationIdNameMappings List A map of operation id names and the new names
output File Location of the output directory.
packageName String The default package to use for the generated objects
parameterNameMappings List A map of parameter names and the new names
project MavenProject The project being built.
removeOperationIdPrefix Boolean To remove operationId prefix (e.g. user_getName => getName)
reservedWordsMappings List A map of reserved names and how they should be escaped
schemaMappings List A map of scheme and the new one
serverVariableOverrides List A map of server variable overrides for specs that support server URL templating
skip Boolean Skip the execution.
skipIfSpecIsUnchanged Boolean Skip the execution if the source file is older than the output folder.
skipOperationExample Boolean To skip examples defined in the operation
skipOverwrite Boolean Specifies if the existing files should be overwritten during the generation.
skipValidateSpec Boolean To skip spec validation
strictSpec Boolean To treat a document strictly against the spec.
supportingFilesToGenerate String A comma separated list of models to generate. All models is the default.
templateDirectory File Folder containing the template files.
templateResourcePath String Resource path containing template files.
typeMappings List A map of swagger spec types and the generated code types to use for them
verbose boolean
相关推荐
黑风风2 分钟前
Spring Boot:如何在业务项目中覆盖基础项目的默认实现
spring boot·后端·python
青云交5 分钟前
Java 大视界 -- Java 大数据在智能教育虚拟实验室建设与实验数据分析中的应用(132)
java·大数据·开发语言·数据存储·智能教育·虚拟实验室·实验分析
程序员杰哥10 分钟前
如何使用Postman,通过Mock的方式测试我们的API
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
胡歌113 分钟前
Java List 接口的核心 API
java·python·list
带娃的IT创业者18 分钟前
《Python实战进阶》No24: PyAutoGUI 实现桌面自动化
开发语言·python·自动化
小学生闹钟22 分钟前
Java 面向对象高级抽象类、接口
java
SKY YEAM24 分钟前
蓝桥杯Python赛道备赛——Day3:排序算法(二)(归并排序、堆排序、桶排序)
python·蓝桥杯·排序算法
无限大625 分钟前
Java 集合框架大师课:集合框架的暗黑料理(六)
java·后端·面试
小学生闹钟26 分钟前
Java面向对象高级-继承、多态
java
恩师小迪27 分钟前
Apache Shiro反序列化漏洞深度剖析:从原理到利用
java·开发语言·python