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
FieldsModifier 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 booleanboolean, toggles whether Unicode identifiers are allowed in names or not, default is false.protected booleanIf true, the generated operation return types will be wrapped in HttpResponse.protected StringSet the api name prefix.protected StringSet the api name suffix.protected StringThe package name for the APIs (controller interfaces).protected booleanIf set to true, generated code will be with suspend methods.protected StringConfigure the date-time format.protected FileThe OpenAPI specification file path relative to the project's root path.protected booleanWhether to ensure parameter names are unique in an operation (rename parameters that are not).Add the enum name mappings.protected booleanIf true, the generated controller interface will be without `@Controller` annotation.protected booleanWrap the operations response in HttpResponse object where non-200 HTTP status codes or additional headers are defined.protected booleanIf set to true, controller and client method will be generated with openAPI annotations.protected booleanSet the implicit headers flag.protected StringSet the implicit headers regex.Add the import mappings.Add the inline schema name mappings.Add the inline schema options.protected StringThe name of the package that can be used for various classes required for invocation.protected booleanIf set to true, @JsonInclude annotation will be with value ALWAYS for required properties in POJO's.protected booleanIf set to true, generated code will be fully compatible with KSP, but not 100% with KAPT.protected StringAllows specifying the language of the generated code.Add the model name mappings.protected StringSet the model name prefix.protected StringSet the model name suffix.protected StringThe package name for the model classes.Add the name mappings.Add the OpenAPI normalizer options.protected FileThe 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 booleanAdd form or body parameters to the beginning of the parameter list.protected org.apache.maven.project.MavenProjectprotected intCount of delimiter for the prefix.protected StringCharacter to use as a delimiter for the prefix.protected booleanGenerate or not required properties constructor.protected List<ResponseBodyMapping>Define parameter mappings that allow using custom types for parameter binding.Add the schema mappings.protected StringConfigure the serialization library.protected booleanSkip examples defined in operations to avoid out of memory errors.protected booleanSkip sorting operations.protected booleanSort model properties to place required parameters before optional parameters.protected booleanSort method arguments to place required parameters before optional parameters.Add the type mappings.protected booleanWhether to generate validation annotations for models and APIs.protected booleanIf set to true, the generated enums check enum value with ignoring case.protected booleanFlag to indicate whether to use the "jakarta" or "javax" package.protected booleanFlag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic.protected booleanWhether to useOptionalfor non-required model properties and API parameters.protected booleanWhether to use reactor types for operation responses.protected booleanWhether to generate sealed model interfaces and classes.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidconfigureBuilder(io.micronaut.openapi.generator.MicronautCodeGeneratorBuilder builder) Configures the OpenAPI generator.final voidexecute()protected abstract booleanDetermines if this mojo must be executed.Methods inherited from class io.micronaut.maven.AbstractMicronautMojo
setLogMethods 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 useOptionalfor 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="true", 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.OutputKindenum. -
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. SeeParameterMappingfor details. -
responseBodyMappings
@Parameter(property="micronaut.openapi.responseBodyMappings") protected List<ResponseBodyMapping> responseBodyMappingsDefine parameter mappings that allow using custom types for parameter binding. SeeResponseBodyMappingfor 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. -
coroutines
If set to true, generated code will be with suspend methods. Ony for kotlin generator.- Since:
- 4.8.0
-
useSealed
Whether to generate sealed model interfaces and classes. Only for java generator.- Since:
- 4.8.0
-
jsonIncludeAlwaysForRequiredFields
@Parameter(property="micronaut.openapi.jsonIncludeAlwaysForRequiredFields") protected boolean jsonIncludeAlwaysForRequiredFieldsIf set to true, @JsonInclude annotation will be with value ALWAYS for required properties in POJO's.- Since:
- 4.8.0
-
requiredPropertiesInConstructor
@Parameter(property="micronaut.openapi.requiredPropertiesInConstructor", defaultValue="true") protected boolean requiredPropertiesInConstructorGenerate or not required properties constructor. Only for java generator.- Since:
- 4.8.0
-
generateControllerAsAbstract
@Parameter(property="micronaut.openapi.generateControllerAsAbstract") protected boolean generateControllerAsAbstractIf true, the generated controller interface will be without `@Controller` annotation.- Since:
- 4.8.0
-
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.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-