openapi generator maven plugin config parameter

这里写自定义目录标题

环境

我使用的版本如下:

<plugin>
	<groupId>org.openapitools</groupId>
	<artifactId>openapi-generator-maven-plugin</artifactId>
	<version>7.12.0</version>
</plugin>

常见配置

<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>

常见参数及其配置说明

参数名类型配置说明
addCompileSourceRootbooleanAdd 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.
addTestCompileSourceRootbooleanAdd 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.
additionalPropertiesjava.util.ListA map of additional properties that can be referenced by the mustache templates
apiNameSuffixjava.lang.StringSets the suffix for api classes.
apiPackagejava.lang.StringThe package to use for generated api objects/classes.
apisToGeneratejava.lang.StringA comma separated list of apis to generate. All apis is the default.
artifactIdjava.lang.StringartifactId in generated pom.xml
artifactVersionjava.lang.Stringartifact version in generated pom.xml
authjava.lang.StringAdds authorization headers when fetching the swagger definitions remotely. " Pass in a URL-encoded string of name:header with a comma separating multiple values.
cleanupOutputboolean
collapsedSpecjava.lang.StringThe path to the collapsed single-file representation of the OpenAPI spec.
configHelpboolean
configOptionsjava.util.MapA map of language-specific parameters as passed with the -c option to the command line
configurationFilejava.lang.StringPath to separate json configuration file.
dryRunboolean
enablePostProcessFilebooleanTo file post-processing hook
engineStringThe name of templating engine to use, "mustache" (default) or "handlebars" (beta)
enumNameMappingsjava.util.ListA map of enum names and the new names
environmentVariablesjava.util.Map
generateAliasAsModelbooleanTo generate alias (array, map) as model
generateApiDocumentationbooleanGenerate the api documentation
generateApiTestsbooleanGenerate the api tests
generateApisbooleanGenerate the apis
generateModelDocumentationbooleanGenerate the model documentation
generateModelTestsbooleanGenerate the model tests
generateModelsbooleanGenerate the models
generateRecursiveDependentModelsbooleanGenerate the models recursively if models should generate selectively (see modelsToGenerate) and all dependent models are to generate
generateSupportingFilesbooleanGenerate the supporting files
generatorNameStringThe name of the generator to use.
gitHostStringGit host, e.g. gitlab.com.
gitRepoIdStringGit repo ID, e.g. openapi-generator.
gitUserIdStringGit user ID, e.g. swagger-api.
globalPropertiesMap
groupIdStringgroupId in generated pom.xml
httpUserAgentStringSets custom User-Agent header value
ignoreFileOverrideStringSets an optional ignoreFileOverride path
importMappingsListA map of classes and the import that should be used for that class
includeCollapsedSpecInArtifactsbooleanIncludes the collapsed spec in the Maven artifacts.
inlineSchemaNameMappingsListA map of inline scheme names and the new names
inlineSchemaOptionsListA map of inline scheme option and the value
inputSpecStringLocation of the OpenAPI spec, as URL or file.
inputSpecRootDirectoryStringLocal root folder with spec files
instantiationTypesListA map of types and the types they should be instantiated as
invokerPackageStringThe package to use for the generated invoker objects
languageSpecificPrimitivesListA map of additional language specific primitive types
libraryStringSets the library
logToStderrBooleanTo write all log messages (not just errors) to STDOUT
mavenProjectMavenProjectThe Maven project context.
mergedFileNameStringName of the file that will contain all merged specs
modelNameMappingsListA map of model names and the new names
modelNamePrefixStringSets the prefix for model enums and classes
modelNameSuffixStringSets the suffix for model enums and classes
modelPackageStringThe package to use for generated model objects/classes
modelsToGenerateStringA comma separated list of models to generate. All models is the default.
mojoMojoExecution
nameMappingsListA map of property names and the new names
openapiGeneratorIgnoreListListA list of openapi-generator-ignore entries
openapiNormalizerListA set of rules for OpenAPI normalizer
operationIdNameMappingsListA map of operation id names and the new names
outputFileLocation of the output directory.
packageNameStringThe default package to use for the generated objects
parameterNameMappingsListA map of parameter names and the new names
projectMavenProjectThe project being built.
removeOperationIdPrefixBooleanTo remove operationId prefix (e.g. user_getName => getName)
reservedWordsMappingsListA map of reserved names and how they should be escaped
schemaMappingsListA map of scheme and the new one
serverVariableOverridesListA map of server variable overrides for specs that support server URL templating
skipBooleanSkip the execution.
skipIfSpecIsUnchangedBooleanSkip the execution if the source file is older than the output folder.
skipOperationExampleBooleanTo skip examples defined in the operation
skipOverwriteBooleanSpecifies if the existing files should be overwritten during the generation.
skipValidateSpecBooleanTo skip spec validation
strictSpecBooleanTo treat a document strictly against the spec.
supportingFilesToGenerateStringA comma separated list of models to generate. All models is the default.
templateDirectoryFileFolder containing the template files.
templateResourcePathStringResource path containing template files.
typeMappingsListA map of swagger spec types and the generated code types to use for them
verboseboolean
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值