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

public abstract class AbstractOpenApiMojo extends AbstractMicronautMojo
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 Details

    • definitionFile

      @Parameter(property="micronaut.openapi.definition", defaultValue="io.micronaut.openapi.invoker", required=true) protected File definitionFile
      The 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 invokerPackageName
      The 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 apiPackageName
      The package name for the APIs (controller interfaces).
    • modelPackageName

      @Parameter(property="micronaut.openapi.model.package.name", defaultValue="io.micronaut.openapi.model", required=true) protected String modelPackageName
      The package name for the model classes.
    • useBeanValidation

      @Parameter(property="micronaut.openapi.use.bean.validation", defaultValue="true", required=true) protected boolean useBeanValidation
      Whether to generate validation annotations for models and APIs.
    • useOptional

      @Parameter(property="micronaut.openapi.use.optional", defaultValue="false", required=true) protected boolean useOptional
      Whether to use Optional for non-required model properties and API parameters.
    • useReactive

      @Parameter(property="micronaut.openapi.use.reactive", defaultValue="true", required=true) protected boolean useReactive
      Whether to use reactor types for operation responses.
    • outputKinds

      @Parameter(property="micronaut.openapi.outputs", required=true, defaultValue="apis,models,supporting_files") protected List<String> outputKinds
      Comma-separated values of output kinds to generate. The values are defined by the MicronautCodeGeneratorEntryPoint.OutputKind enum.
    • outputDirectory

      @Parameter(defaultValue="${project.build.directory}/generated-sources/openapi", required=true) protected File outputDirectory
      The output directory to which all the sources will be generated.
    • parameterMappings

      @Parameter(property="micronaut.openapi.parameterMappings") protected List<ParameterMapping> parameterMappings
      Define parameter mappings that allow using custom types for parameter binding. See ParameterMapping for details.
    • responseBodyMappings

      @Parameter(property="micronaut.openapi.responseBodyMappings") protected List<ResponseBodyMapping> responseBodyMappings
      Define parameter mappings that allow using custom types for parameter binding. See ResponseBodyMapping for details.
  • Constructor Details

    • AbstractOpenApiMojo

      public AbstractOpenApiMojo()
  • Method Details

    • isEnabled

      protected abstract boolean 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