Package io.micronaut.maven.openapi
Class AbstractOpenApiMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
io.micronaut.maven.AbstractMicronautMojo
io.micronaut.maven.openapi.AbstractOpenApiMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
OpenApiClientMojo
,OpenApiGenericMojo
,OpenApiServerMojo
Base class for OpenAPI generator mojos. This provides the common
parameters for all generators and the invoker logic. Subclasses
must implement the
isEnabled()
and configureBuilder(MicronautCodeGeneratorBuilder)
methods.-
Field Summary
Modifier and TypeFieldDescriptionAdditional annotations for enum type (class level annotations).Additional annotations for model type (class level annotations).Additional annotations for oneOf interfaces (class level annotations).Additional generator properties.protected boolean
boolean, toggles whether Unicode identifiers are allowed in names or not, default is false.protected boolean
If true, the generated operation return types will be wrapped in HttpResponse.protected String
Set the api name prefix.protected String
Set the api name suffix.protected String
The package name for the APIs (controller interfaces).protected String
Configure the date-time format.protected File
The OpenAPI specification file path relative to the project's root path.protected boolean
Whether to ensure parameter names are unique in an operation (rename parameters that are not).Add the enum name mappings.protected boolean
Wrap the operations response in HttpResponse object where non-200 HTTP status codes or additional headers are defined.protected boolean
If set to true, controller and client method will be generated with openAPI annotations.protected boolean
Set the implicit headers flag.protected String
Set the implicit headers regex.Add the import mappings.Add the inline schema name mappings.Add the inline schema options.protected String
The name of the package that can be used for various classes required for invocation.protected boolean
If set to true, generated code will be fully compatible with KSP, but not 100% with KAPT.protected String
Allows specifying the language of the generated code.Add the model name mappings.protected String
Set the model name prefix.protected String
Set the model name suffix.protected String
The package name for the model classes.Add the name mappings.Add the OpenAPI normalizer options.protected File
The output directory to which all the sources will be generated.Comma-separated values of output kinds to generate.protected List<ParameterMapping>
Define parameter mappings that allow using custom types for parameter binding.protected boolean
Add form or body parameters to the beginning of the parameter list.protected org.apache.maven.project.MavenProject
protected int
Count of delimiter for the prefix.protected String
Character to use as a delimiter for the prefix.protected List<ResponseBodyMapping>
Define parameter mappings that allow using custom types for parameter binding.Add the schema mappings.protected String
Configure the serialization library.protected boolean
Skip examples defined in operations to avoid out of memory errors.protected boolean
Skip sorting operations.protected boolean
Sort model properties to place required parameters before optional parameters.protected boolean
Sort method arguments to place required parameters before optional parameters.Add the type mappings.protected boolean
Whether to generate validation annotations for models and APIs.protected boolean
If set to true, the generated enums check enum value with ignoring case.protected boolean
Flag to indicate whether to use the "jakarta" or "javax" package.protected boolean
Flag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic.protected boolean
Whether to useOptional
for non-required model properties and API parameters.protected boolean
Whether to use reactor types for operation responses.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
configureBuilder
(io.micronaut.openapi.generator.MicronautCodeGeneratorBuilder builder) Configures the OpenAPI generator.final void
execute()
protected abstract boolean
Determines if this mojo must be executed.Methods inherited from class io.micronaut.maven.AbstractMicronautMojo
setLog
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setPluginContext
-
Field Details
-
definitionFile
@Parameter(property="micronaut.openapi.definition", defaultValue="io.micronaut.openapi.invoker", required=true) protected File definitionFileThe OpenAPI specification file path relative to the project's root path. -
invokerPackageName
@Parameter(property="micronaut.openapi.invoker.package.name", defaultValue="io.micronaut.openapi.invoker", required=true) protected String invokerPackageNameThe name of the package that can be used for various classes required for invocation. -
apiPackageName
@Parameter(property="micronaut.openapi.api.package.name", defaultValue="io.micronaut.openapi.api", required=true) protected String apiPackageNameThe package name for the APIs (controller interfaces). -
modelPackageName
@Parameter(property="micronaut.openapi.model.package.name", defaultValue="io.micronaut.openapi.model", required=true) protected String modelPackageNameThe package name for the model classes. -
useBeanValidation
@Parameter(property="micronaut.openapi.use.bean.validation", defaultValue="true", required=true) protected boolean useBeanValidationWhether to generate validation annotations for models and APIs. -
useOneOfInterfaces
@Parameter(property="micronaut.openapi.use.one.of.interfaces", defaultValue="true", required=true) protected boolean useOneOfInterfacesFlag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic. -
useOptional
@Parameter(property="micronaut.openapi.use.optional", defaultValue="false", required=true) protected boolean useOptionalWhether to useOptional
for non-required model properties and API parameters. -
useReactive
@Parameter(property="micronaut.openapi.use.reactive", defaultValue="true", required=true) protected boolean useReactiveWhether to use reactor types for operation responses. -
serializationFramework
@Parameter(property="micronaut.openapi.serialization.framework", defaultValue="MICRONAUT_SERDE_JACKSON", required=true) protected String serializationFrameworkConfigure the serialization library. -
alwaysUseGenerateHttpResponse
@Parameter(property="micronaut.openapi.always.use.generate.http.response", defaultValue="false", required=true) protected boolean alwaysUseGenerateHttpResponseIf true, the generated operation return types will be wrapped in HttpResponse. -
generateHttpResponseWhereRequired
@Parameter(property="micronaut.openapi.generate.http.response.where.required", defaultValue="false", required=true) protected boolean generateHttpResponseWhereRequiredWrap the operations response in HttpResponse object where non-200 HTTP status codes or additional headers are defined. -
ksp
@Parameter(property="micronaut.openapi.ksp", defaultValue="false", required=true) protected boolean kspIf set to true, generated code will be fully compatible with KSP, but not 100% with KAPT. -
dateTimeFormat
@Parameter(property="micronaut.openapi.date.time.format", defaultValue="ZONED_DATETIME", required=true) protected String dateTimeFormatConfigure the date-time format. -
outputKinds
@Parameter(property="micronaut.openapi.outputs", required=true, defaultValue="apis,models,supporting_files") protected List<String> outputKindsComma-separated values of output kinds to generate. The values are defined by theMicronautCodeGeneratorEntryPoint.OutputKind
enum. -
outputDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/openapi", required=true) protected File outputDirectoryThe output directory to which all the sources will be generated. -
parameterMappings
@Parameter(property="micronaut.openapi.parameterMappings") protected List<ParameterMapping> parameterMappingsDefine parameter mappings that allow using custom types for parameter binding. SeeParameterMapping
for details. -
responseBodyMappings
@Parameter(property="micronaut.openapi.responseBodyMappings") protected List<ResponseBodyMapping> responseBodyMappingsDefine parameter mappings that allow using custom types for parameter binding. SeeResponseBodyMapping
for details. -
schemaMapping
Add the schema mappings. -
importMapping
Add the import mappings. -
nameMapping
Add the name mappings. -
typeMapping
Add the type mappings. -
enumNameMapping
@Parameter(property="micronaut.openapi.enumNameMapping") protected Map<String,String> enumNameMappingAdd the enum name mappings. -
modelNameMapping
@Parameter(property="micronaut.openapi.modelNameMapping") protected Map<String,String> modelNameMappingAdd the model name mappings. -
inlineSchemaNameMapping
@Parameter(property="micronaut.openapi.inlineSchemaNameMapping") protected Map<String,String> inlineSchemaNameMappingAdd the inline schema name mappings. -
inlineSchemaOption
@Parameter(property="micronaut.openapi.inlineSchemaOption") protected Map<String,String> inlineSchemaOptionAdd the inline schema options. -
openapiNormalizer
@Parameter(property="micronaut.openapi.openapiNormalizer") protected Map<String,String> openapiNormalizerAdd the OpenAPI normalizer options. -
apiNamePrefix
Set the api name prefix. -
apiNameSuffix
Set the api name suffix. -
modelNamePrefix
Set the model name prefix. -
modelNameSuffix
Set the model name suffix. -
lang
Allows specifying the language of the generated code.- Since:
- 4.3.0
-
useEnumCaseInsensitive
@Parameter(property="micronaut.openapi.useEnumCaseInsensitive", defaultValue="false") protected boolean useEnumCaseInsensitiveIf set to true, the generated enums check enum value with ignoring case. -
additionalEnumTypeAnnotations
@Parameter(property="micronaut.openapi.additionalEnumTypeAnnotations") protected List<String> additionalEnumTypeAnnotationsAdditional annotations for enum type (class level annotations). -
additionalModelTypeAnnotations
@Parameter(property="micronaut.openapi.additionalModelTypeAnnotations") protected List<String> additionalModelTypeAnnotationsAdditional annotations for model type (class level annotations). -
additionalOneOfTypeAnnotations
@Parameter(property="micronaut.openapi.additionalOneOfTypeAnnotations") protected List<String> additionalOneOfTypeAnnotationsAdditional annotations for oneOf interfaces (class level annotations). -
additionalProperties
@Parameter(property="micronaut.openapi.additionalProperties") protected Map<String,Object> additionalPropertiesAdditional generator properties. -
generateSwaggerAnnotations
@Parameter(property="micronaut.openapi.generateSwaggerAnnotations", defaultValue="false") protected boolean generateSwaggerAnnotationsIf set to true, controller and client method will be generated with openAPI annotations. -
implicitHeaders
@Parameter(property="micronaut.openapi.implicitHeaders", defaultValue="false") protected boolean implicitHeadersSet the implicit headers flag. -
implicitHeadersRegex
Set the implicit headers regex. -
useJakartaEe
@Parameter(property="micronaut.openapi.useJakartaEe", defaultValue="true") protected boolean useJakartaEeFlag to indicate whether to use the "jakarta" or "javax" package. -
sortParamsByRequiredFlag
@Parameter(property="micronaut.openapi.sortParamsByRequiredFlag", defaultValue="true") protected boolean sortParamsByRequiredFlagSort method arguments to place required parameters before optional parameters. Default: true -
skipOperationExample
@Parameter(property="micronaut.openapi.skipOperationExample") protected boolean skipOperationExampleSkip examples defined in operations to avoid out of memory errors. Default: false -
skipSortingOperations
@Parameter(property="micronaut.openapi.skipSortingOperations") protected boolean skipSortingOperationsSkip sorting operations. Default: false -
removeOperationIdPrefixDelimiter
@Parameter(property="micronaut.openapi.removeOperationIdPrefixDelimiter", defaultValue="_") protected String removeOperationIdPrefixDelimiterCharacter to use as a delimiter for the prefix. Default: '_' -
removeOperationIdPrefixCount
@Parameter(property="micronaut.openapi.removeOperationIdPrefixCount", defaultValue="1") protected int removeOperationIdPrefixCountCount of delimiter for the prefix. Use -1 for last. Default: 1 -
sortModelPropertiesByRequiredFlag
@Parameter(property="micronaut.openapi.sortModelPropertiesByRequiredFlag", defaultValue="true") protected boolean sortModelPropertiesByRequiredFlagSort model properties to place required parameters before optional parameters. -
ensureUniqueParams
@Parameter(property="micronaut.openapi.ensureUniqueParams", defaultValue="true") protected boolean ensureUniqueParamsWhether to ensure parameter names are unique in an operation (rename parameters that are not). -
allowUnicodeIdentifiers
@Parameter(property="micronaut.openapi.allowUnicodeIdentifiers") protected boolean allowUnicodeIdentifiersboolean, toggles whether Unicode identifiers are allowed in names or not, default is false. -
prependFormOrBodyParameters
@Parameter(property="micronaut.openapi.prependFormOrBodyParameters") protected boolean prependFormOrBodyParametersAdd form or body parameters to the beginning of the parameter list. -
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
-
-
Constructor Details
-
AbstractOpenApiMojo
public AbstractOpenApiMojo()
-
-
Method Details
-
isEnabled
Determines if this mojo must be executed.- Returns:
- true if the mojo is enabled
-
configureBuilder
protected abstract void configureBuilder(io.micronaut.openapi.generator.MicronautCodeGeneratorBuilder builder) throws org.apache.maven.plugin.MojoExecutionException Configures the OpenAPI generator. When this method is called, common properties shared by all generators have already been configured, so this method should only take care of configuring the generator specific parameters.- Parameters:
builder
- the generator configuration builder- Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-