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
相关推荐
BreezeDove4 分钟前
IDEA安装&迁移IDEA配置数据位置
java·ide·intellij-idea
太阳之神aboluo8 分钟前
压测软件-Jmeter
java·运维·jmeter
程序员三藏12 分钟前
如何使用Jmeter进行压力测试?
自动化测试·软件测试·python·测试工具·jmeter·测试用例·压力测试
carpell16 分钟前
【语义分割专栏】3:Segnet原理篇
人工智能·python·深度学习·计算机视觉·语义分割
24K纯学渣17 分钟前
Python编码格式化之PEP8编码规范
开发语言·ide·python·pycharm
怒视天下19 分钟前
零基础玩转Python生物信息学:数据分析与算法实现
开发语言·python
编程乐学(Arfan开发工程师)21 分钟前
42、响应处理-【源码分析】-浏览器与PostMan内容协商完全适配
java·spring boot·后端·测试工具·lua·postman
珹洺26 分钟前
数据库系统概论(十七)超详细讲解数据库规范化与五大范式(从函数依赖到多值依赖,再到五大范式,附带例题,表格,知识图谱对比带你一步步掌握)
java·数据库·sql·安全·oracle
用户791177242358328 分钟前
黑马点评【基于redis实现共享session登录】
java·redis
网安INF31 分钟前
CVE-2023-25194源码分析与漏洞复现(Kafka JNDI注入)
java·web安全·网络安全·kafka·漏洞·jndi注入