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
相关推荐
小柯南敲键盘14 分钟前
跨马翻译:批量图片与视频字幕翻译,支持智能抠图
大数据·人工智能·python·音视频
自强的小白15 分钟前
重点!起始时间和结束时间与创建时间和修改时间的区别(localdate与LocaldateTIME区别)以及增删改查什么时候设置目前时间(添加和更新员工时)
java
雪的季节26 分钟前
Python 线程同步与异步编程 全解析
java·开发语言
吃饱了得干活38 分钟前
缓存与数据库一致性:从理论到实战
java·后端·面试
再渊42 分钟前
基因归因到底怎么计算的?
python·深度学习·机器学习
520拼好饭被践踏1 小时前
JAVA+Agent学习day22
java·开发语言·后端·学习
E_ICEBLUE1 小时前
Python 拆分 Excel 文件:使用 Spire.XLS 实现按工作表、行、列和条件拆分
python·excel
笨蛋不要掉眼泪1 小时前
Java虚拟机:堆的参数配置
java·开发语言·jvm
霸道流氓气质1 小时前
SpringBoot中使用JasperReports 报表引擎 — 介绍、原理与使用实践
java·spring boot·后端
aiqianji1 小时前
有哪些稳定的AI短篇小说写作软件可以推荐?
人工智能·python