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 TypeFieldDescriptionprotected String
The package name for the APIs (controller interfaces).protected File
The OpenAPI specification file path relative to the project's root path.protected String
The name of the package that can be used for various classes required for invocation.protected String
Allows specifying the language of the generated code.protected String
The package name for the model classes.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 List<ResponseBodyMapping>
Define parameter mappings that allow using custom types for parameter binding.protected boolean
Whether to generate validation annotations for models and APIs.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. -
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. -
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. -
lang
Allows specifying the language of the generated code.- Since:
- 4.3.0
-
-
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
-