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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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.
    protected List<String>
    Comma-separated values of output kinds to generate.
    Define parameter mappings that allow using custom types for parameter binding.
    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 use Optional 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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    configureBuilder(io.micronaut.openapi.generator.MicronautCodeGeneratorBuilder builder)
    Configures the OpenAPI generator.
    final void
     
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.
    • lang

      @Parameter(property="micronaut.openapi.lang", defaultValue="java") protected String lang
      Allows specifying the language of the generated code.
      Since:
      4.3.0
  • Constructor Details

  • 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