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
相关推荐
mortimer1 小时前
安装NVIDIA Parakeet时,我遇到的两个Pip“小插曲”
python·github
@昵称不存在2 小时前
Flask input 和datalist结合
后端·python·flask
赵英英俊2 小时前
Python day25
python
东林牧之2 小时前
Django+celery异步:拿来即用,可移植性高
后端·python·django
何双新3 小时前
基于Tornado的WebSocket实时聊天系统:从零到一构建与解析
python·websocket·tornado
YuTaoShao3 小时前
【LeetCode 热题 100】131. 分割回文串——回溯
java·算法·leetcode·深度优先
源码_V_saaskw3 小时前
JAVA图文短视频交友+自营商城系统源码支持小程序+Android+IOS+H5
java·微信小程序·小程序·uni-app·音视频·交友
超浪的晨3 小时前
Java UDP 通信详解:从基础到实战,彻底掌握无连接网络编程
java·开发语言·后端·学习·个人开发
AntBlack3 小时前
从小不学好 ,影刀 + ddddocr 实现图片验证码认证自动化
后端·python·计算机视觉
凪卄12133 小时前
图像预处理 二
人工智能·python·深度学习·计算机视觉·pycharm