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.
    • useOneOfInterfaces

      @Parameter(property="micronaut.openapi.use.one.of.interfaces", defaultValue="true", required=true) protected boolean useOneOfInterfaces
      Flag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic.
    • 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.
    • serializationFramework

      @Parameter(property="micronaut.openapi.serialization.framework", defaultValue="MICRONAUT_SERDE_JACKSON", required=true) protected String serializationFramework
      Configure the serialization library.
    • alwaysUseGenerateHttpResponse

      @Parameter(property="micronaut.openapi.always.use.generate.http.response", defaultValue="false", required=true) protected boolean alwaysUseGenerateHttpResponse
      If 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 generateHttpResponseWhereRequired
      Wrap 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 ksp
      If 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 dateTimeFormat
      Configure the date-time format.
    • 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.
    • schemaMapping

      @Parameter(property="micronaut.openapi.schemaMapping") protected Map<String,String> schemaMapping
      Add the schema mappings.
    • importMapping

      @Parameter(property="micronaut.openapi.importMapping") protected Map<String,String> importMapping
      Add the import mappings.
    • nameMapping

      @Parameter(property="micronaut.openapi.nameMapping") protected Map<String,String> nameMapping
      Add the name mappings.
    • typeMapping

      @Parameter(property="micronaut.openapi.typeMapping") protected Map<String,String> typeMapping
      Add the type mappings.
    • enumNameMapping

      @Parameter(property="micronaut.openapi.enumNameMapping") protected Map<String,String> enumNameMapping
      Add the enum name mappings.
    • modelNameMapping

      @Parameter(property="micronaut.openapi.modelNameMapping") protected Map<String,String> modelNameMapping
      Add the model name mappings.
    • inlineSchemaNameMapping

      @Parameter(property="micronaut.openapi.inlineSchemaNameMapping") protected Map<String,String> inlineSchemaNameMapping
      Add the inline schema name mappings.
    • inlineSchemaOption

      @Parameter(property="micronaut.openapi.inlineSchemaOption") protected Map<String,String> inlineSchemaOption
      Add the inline schema options.
    • openapiNormalizer

      @Parameter(property="micronaut.openapi.openapiNormalizer") protected Map<String,String> openapiNormalizer
      Add the OpenAPI normalizer options.
    • apiNamePrefix

      @Parameter(property="micronaut.openapi.apiNamePrefix") protected String apiNamePrefix
      Set the api name prefix.
    • apiNameSuffix

      @Parameter(property="micronaut.openapi.apiNameSuffix") protected String apiNameSuffix
      Set the api name suffix.
    • modelNamePrefix

      @Parameter(property="micronaut.openapi.modelNamePrefix") protected String modelNamePrefix
      Set the model name prefix.
    • modelNameSuffix

      @Parameter(property="micronaut.openapi.modelNameSuffix") protected String modelNameSuffix
      Set the model name suffix.
    • lang

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

      @Parameter(property="micronaut.openapi.useEnumCaseInsensitive", defaultValue="false") protected boolean useEnumCaseInsensitive
      If set to true, the generated enums check enum value with ignoring case.
    • additionalEnumTypeAnnotations

      @Parameter(property="micronaut.openapi.additionalEnumTypeAnnotations") protected List<String> additionalEnumTypeAnnotations
      Additional annotations for enum type (class level annotations).
    • additionalModelTypeAnnotations

      @Parameter(property="micronaut.openapi.additionalModelTypeAnnotations") protected List<String> additionalModelTypeAnnotations
      Additional annotations for model type (class level annotations).
    • additionalOneOfTypeAnnotations

      @Parameter(property="micronaut.openapi.additionalOneOfTypeAnnotations") protected List<String> additionalOneOfTypeAnnotations
      Additional annotations for oneOf interfaces (class level annotations).
    • additionalProperties

      @Parameter(property="micronaut.openapi.additionalProperties") protected Map<String,Object> additionalProperties
      Additional generator properties.
    • generateSwaggerAnnotations

      @Parameter(property="micronaut.openapi.generateSwaggerAnnotations", defaultValue="false") protected boolean generateSwaggerAnnotations
      If set to true, controller and client method will be generated with openAPI annotations.
    • implicitHeaders

      @Parameter(property="micronaut.openapi.implicitHeaders", defaultValue="false") protected boolean implicitHeaders
      Set the implicit headers flag.
    • implicitHeadersRegex

      @Parameter(property="micronaut.openapi.implicitHeadersRegex") protected String implicitHeadersRegex
      Set the implicit headers regex.
    • useJakartaEe

      @Parameter(property="micronaut.openapi.useJakartaEe", defaultValue="true") protected boolean useJakartaEe
      Flag to indicate whether to use the "jakarta" or "javax" package.
    • sortParamsByRequiredFlag

      @Parameter(property="micronaut.openapi.sortParamsByRequiredFlag", defaultValue="true") protected boolean sortParamsByRequiredFlag
      Sort method arguments to place required parameters before optional parameters. Default: true
    • skipOperationExample

      @Parameter(property="micronaut.openapi.skipOperationExample") protected boolean skipOperationExample
      Skip examples defined in operations to avoid out of memory errors. Default: false
    • skipSortingOperations

      @Parameter(property="micronaut.openapi.skipSortingOperations") protected boolean skipSortingOperations
      Skip sorting operations. Default: false
    • removeOperationIdPrefixDelimiter

      @Parameter(property="micronaut.openapi.removeOperationIdPrefixDelimiter", defaultValue="_") protected String removeOperationIdPrefixDelimiter
      Character to use as a delimiter for the prefix. Default: '_'
    • removeOperationIdPrefixCount

      @Parameter(property="micronaut.openapi.removeOperationIdPrefixCount", defaultValue="1") protected int removeOperationIdPrefixCount
      Count of delimiter for the prefix. Use -1 for last. Default: 1
    • sortModelPropertiesByRequiredFlag

      @Parameter(property="micronaut.openapi.sortModelPropertiesByRequiredFlag", defaultValue="true") protected boolean sortModelPropertiesByRequiredFlag
      Sort model properties to place required parameters before optional parameters.
    • ensureUniqueParams

      @Parameter(property="micronaut.openapi.ensureUniqueParams", defaultValue="true") protected boolean ensureUniqueParams
      Whether to ensure parameter names are unique in an operation (rename parameters that are not).
    • allowUnicodeIdentifiers

      @Parameter(property="micronaut.openapi.allowUnicodeIdentifiers") protected boolean allowUnicodeIdentifiers
      boolean, toggles whether Unicode identifiers are allowed in names or not, default is false.
    • prependFormOrBodyParameters

      @Parameter(property="micronaut.openapi.prependFormOrBodyParameters") protected boolean prependFormOrBodyParameters
      Add 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

  • 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