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
相关推荐
梦醒沉醉24 分钟前
Python教程(四)——数据结构
python
xixixiLucky26 分钟前
配置Java Selenium Web自动化测试环境
java·前端·selenium
Adolf_199328 分钟前
django的权限角色管理(RBAC)
数据库·python·django
weixin_3077791337 分钟前
使用FastAPI和Apache Flink构建跨环境数据管道
redis·python·云计算·fastapi·aws
Code_流苏1 小时前
《Python星球日记》 第55天:迁移学习与预训练模型
python·深度学习·微调·resnet·迁移学习·预训练模型·超参数优化
淘源码A1 小时前
小微企业SaaS ERP管理系统,SpringBoot+Vue+ElementUI+UniAPP
java·源码·saas·erp·erp系统·erp源码
我是唐青枫1 小时前
Java 原生异步编程与Spring 异步编程 详解
java
小妖6661 小时前
vue2 provide 后 inject 数据不是响应式的,不实时更新
java·服务器·前端
zhang23839061541 小时前
idea如何快速生成测试类
java·ide·intellij-idea
琢磨先生David2 小时前
Java 24:重构数字信任边界 —— 后量子时代的智能安全防御体系构建
java·安全·重构