Package io.micronaut.openapi.generator
Interface MicronautCodeGeneratorOptionsBuilder
public interface MicronautCodeGeneratorOptionsBuilder
Builder for generic options that the Micronaut code generator supports.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The possible date-time formatting configurations.static enum
The possible languages for generator. -
Method Summary
Modifier and TypeMethodDescriptionwithAdditionalEnumTypeAnnotations
(List<String> additionalEnumTypeAnnotations) Additional annotations for enum type (class level annotations).withAdditionalModelTypeAnnotations
(List<String> additionalModelTypeAnnotations) Additional annotations for model type (class level annotations).withAdditionalOneOfTypeAnnotations
(List<String> additionalOneOfTypeAnnotations) Additional annotations for oneOf interfaces (class level annotations).withAdditionalProperties
(Map<String, Object> additionalProperties) Additional generator properties.withAllowUnicodeIdentifiers
(boolean allowUnicodeIdentifiers) boolean, toggles whether Unicode identifiers are allowed in names or not, default is false.withApiNamePrefix
(String apiNamePrefix) Set the api name prefix.withApiNameSuffix
(String apiNameSuffix) Set the api name suffix.withApiPackage
(String apiPackage) Sets the package of the generated API classes.withArtifactId
(String artifactId) Sets the artifact id of the project.withBeanValidation
(boolean beanValidation) If set to true, the generated code will use bean validation.Configure the date-time format.withEnsureUniqueParams
(boolean ensureUniqueParams) Whether to ensure parameter names are unique in an operation (rename parameters that are not).withEnumNameMapping
(Map<String, String> enumNameMapping) Add the enum name mappings.withGenerateHttpResponseAlways
(boolean generateHttpResponseAlways) If true, the generated operation return types will be wrapped in HttpResponse.withGenerateHttpResponseWhereRequired
(boolean generateHttpResponseWhereRequired) Wrap the operations response in HttpResponse object where non-200 HTTP status codes or additional headers are defined.withGenerateSwaggerAnnotations
(boolean generateSwaggerAnnotations) If set to true, controller and client method will be generated with openAPI annotations.withImplicitHeaders
(boolean implicitHeaders) Set the implicit headers flag.withImplicitHeadersRegex
(String implicitHeadersRegex) Set the implicit headers regex.withImportMapping
(Map<String, String> importMapping) Add the import mappings.withInlineSchemaNameMapping
(Map<String, String> inlineSchemaNameMapping) Add the inline schema name mappings.withInlineSchemaOption
(Map<String, String> inlineSchemaOption) Add the inline schema options.withInvokerPackage
(String invokerPackage) Sets the package of the generated invoker classes.Sets the generator language.withModelNameMapping
(Map<String, String> modelNameMapping) Add the model name mappings.withModelNamePrefix
(String modelNamePrefix) Set the model name prefix.withModelNameSuffix
(String modelNameSuffix) Set the model name suffix.withModelPackage
(String modelPackage) Sets the package of the generated model classes.withNameMapping
(Map<String, String> nameMapping) Add the name mappings.withOpenapiNormalizer
(Map<String, String> openapiNormalizer) Add the OpenAPI normalizer options.withOptional
(boolean optional) If set to true, the generated code will make use ofOptional
.withParameterMappings
(List<ParameterMapping> parameterMappings) Add the parameter mappings.withPrependFormOrBodyParameters
(boolean prependFormOrBodyParameters) Add form or body parameters to the beginning of the parameter list.withReactive
(boolean reactive) If set to true, the generator will use reactive types.withRemoveOperationIdPrefixCount
(int removeOperationIdPrefixCount) Count of delimiter for the prefix.withRemoveOperationIdPrefixDelimiter
(String removeOperationIdPrefixDelimiter) Character to use as a delimiter for the prefix.withResponseBodyMappings
(List<ResponseBodyMapping> responseBodyMappings) Add the response body mappings.withSchemaMapping
(Map<String, String> schemaMapping) Add the schema mappings.Configure the serialization library.withSkipOperationExample
(boolean skipOperationExample) Skip examples defined in operations to avoid out of memory errors.withSkipSortingOperations
(boolean skipSortingOperations) Skip sorting operations.withSortModelPropertiesByRequiredFlag
(boolean sortModelPropertiesByRequiredFlag) Sort model properties to place required parameters before optional parameters.withSortParamsByRequiredFlag
(boolean sortParamsByRequiredFlag) Sort method arguments to place required parameters before optional parameters.withTestFramework
(MicronautCodeGeneratorEntryPoint.TestFramework testFramework) Configures the test framework to use for generated tests.withTypeMapping
(Map<String, String> typeMapping) Add the type mappings.withUseEnumCaseInsensitive
(boolean useEnumCaseInsensitive) If set to true, the generated enums check enum value with ignoring case.withUseJakartaEe
(boolean useJakartaEe) Flag to indicate whether to use the "jakarta" or "javax" package.withUseOneOfInterfaces
(boolean useOneOfInterfaces) Flag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic.
-
Method Details
-
withLang
MicronautCodeGeneratorOptionsBuilder withLang(MicronautCodeGeneratorOptionsBuilder.GeneratorLanguage lang) Sets the generator language.- Parameters:
lang
- generator language- Returns:
- this builder
-
withApiPackage
Sets the package of the generated API classes.- Parameters:
apiPackage
- the package name- Returns:
- this builder
-
withInvokerPackage
Sets the package of the generated invoker classes.- Parameters:
invokerPackage
- the package name- Returns:
- this builder
-
withModelPackage
Sets the package of the generated model classes.- Parameters:
modelPackage
- the package name- Returns:
- this builder
-
withArtifactId
Sets the artifact id of the project.- Parameters:
artifactId
- the artifact id- Returns:
- this builder
-
withParameterMappings
MicronautCodeGeneratorOptionsBuilder withParameterMappings(List<ParameterMapping> parameterMappings) Add the parameter mappings.- Parameters:
parameterMappings
- the parameter mappings specified by aParameterMapping
objects- Returns:
- this builder
-
withResponseBodyMappings
MicronautCodeGeneratorOptionsBuilder withResponseBodyMappings(List<ResponseBodyMapping> responseBodyMappings) Add the response body mappings.- Parameters:
responseBodyMappings
- the response body mappings specified by aResponseBodyMapping
objects- Returns:
- this builder
-
withSchemaMapping
Add the schema mappings.- Parameters:
schemaMapping
- the schema mappings- Returns:
- this builder
-
withImportMapping
Add the import mappings.- Parameters:
importMapping
- the import mappings- Returns:
- this builder
-
withNameMapping
Add the name mappings.- Parameters:
nameMapping
- the name mappings- Returns:
- this builder
-
withTypeMapping
Add the type mappings.- Parameters:
typeMapping
- the type mappings- Returns:
- this builder
-
withEnumNameMapping
Add the enum name mappings.- Parameters:
enumNameMapping
- the enum name mappings- Returns:
- this builder
-
withModelNameMapping
Add the model name mappings.- Parameters:
modelNameMapping
- the model name mappings- Returns:
- this builder
-
withInlineSchemaNameMapping
MicronautCodeGeneratorOptionsBuilder withInlineSchemaNameMapping(Map<String, String> inlineSchemaNameMapping) Add the inline schema name mappings.- Parameters:
inlineSchemaNameMapping
- the inline schema name mappings- Returns:
- this builder
-
withInlineSchemaOption
Add the inline schema options.- Parameters:
inlineSchemaOption
- the inline schema options- Returns:
- this builder
-
withOpenapiNormalizer
Add the OpenAPI normalizer options.- Parameters:
openapiNormalizer
- the OpenAPI normalizer options- Returns:
- this builder
-
withApiNamePrefix
Set the api name prefix.- Parameters:
apiNamePrefix
- the api name prefix- Returns:
- this builder
-
withApiNameSuffix
Set the api name suffix.- Parameters:
apiNameSuffix
- the api name suffix- Returns:
- this builder
-
withModelNamePrefix
Set the model name prefix.- Parameters:
modelNamePrefix
- the model name prefix- Returns:
- this builder
-
withModelNameSuffix
Set the model name suffix.- Parameters:
modelNameSuffix
- the model name suffix- Returns:
- this builder
-
withImplicitHeaders
Set the implicit headers flag.- Parameters:
implicitHeaders
- implicit headers- Returns:
- this builder
-
withImplicitHeadersRegex
Set the implicit headers regex.- Parameters:
implicitHeadersRegex
- implicit headers regex- Returns:
- this builder
-
withReactive
If set to true, the generator will use reactive types.- Parameters:
reactive
- the reactive flag- Returns:
- this builder
-
withGenerateHttpResponseAlways
MicronautCodeGeneratorOptionsBuilder withGenerateHttpResponseAlways(boolean generateHttpResponseAlways) If true, the generated operation return types will be wrapped in HttpResponse.- Parameters:
generateHttpResponseAlways
- the wrapping flag- Returns:
- this builder
-
withGenerateHttpResponseWhereRequired
MicronautCodeGeneratorOptionsBuilder withGenerateHttpResponseWhereRequired(boolean generateHttpResponseWhereRequired) Wrap the operations response in HttpResponse object where non-200 HTTP status codes or additional headers are defined.- Parameters:
generateHttpResponseWhereRequired
- the wrapping flag- Returns:
- this builder
-
withGenerateSwaggerAnnotations
MicronautCodeGeneratorOptionsBuilder withGenerateSwaggerAnnotations(boolean generateSwaggerAnnotations) If set to true, controller and client method will be generated with openAPI annotations.- Parameters:
generateSwaggerAnnotations
- the generate swagger annotations flag- Returns:
- this builder
-
withBeanValidation
If set to true, the generated code will use bean validation.- Parameters:
beanValidation
- the bean validation flag- Returns:
- this builder
-
withUseEnumCaseInsensitive
If set to true, the generated enums check enum value with ignoring case.- Parameters:
useEnumCaseInsensitive
- the useEnumCaseInsensitive flag- Returns:
- this builder
-
withOptional
If set to true, the generated code will make use ofOptional
.- Parameters:
optional
- the optional flag- Returns:
- this builder
-
withTestFramework
MicronautCodeGeneratorOptionsBuilder withTestFramework(MicronautCodeGeneratorEntryPoint.TestFramework testFramework) Configures the test framework to use for generated tests.- Parameters:
testFramework
- the test framework- Returns:
- this builder
-
withSerializationLibrary
Configure the serialization library.- Parameters:
library
- the serialization library.- Returns:
- this builder
-
withDateTimeFormat
MicronautCodeGeneratorOptionsBuilder withDateTimeFormat(MicronautCodeGeneratorOptionsBuilder.DateTimeFormat format) Configure the date-time format.- Parameters:
format
- the date-time format.- Returns:
- this builder
-
withUseOneOfInterfaces
Flag to indicate whether to use the utils.OneOfImplementorAdditionalData related logic.- Parameters:
useOneOfInterfaces
- if true, then use the utils.OneOfImplementorAdditionalData related logic.- Returns:
- this builder
-
withAdditionalEnumTypeAnnotations
MicronautCodeGeneratorOptionsBuilder withAdditionalEnumTypeAnnotations(List<String> additionalEnumTypeAnnotations) Additional annotations for enum type (class level annotations).- Parameters:
additionalEnumTypeAnnotations
- additional annotations for enum type (class level annotations).- Returns:
- this builder
-
withAdditionalModelTypeAnnotations
MicronautCodeGeneratorOptionsBuilder withAdditionalModelTypeAnnotations(List<String> additionalModelTypeAnnotations) Additional annotations for model type (class level annotations).- Parameters:
additionalModelTypeAnnotations
- additional annotations for model type (class level annotations).- Returns:
- this builder
-
withAdditionalOneOfTypeAnnotations
MicronautCodeGeneratorOptionsBuilder withAdditionalOneOfTypeAnnotations(List<String> additionalOneOfTypeAnnotations) Additional annotations for oneOf interfaces (class level annotations).- Parameters:
additionalOneOfTypeAnnotations
- additional annotations for oneOf interfaces (class level annotations).- Returns:
- this builder
-
withAdditionalProperties
MicronautCodeGeneratorOptionsBuilder withAdditionalProperties(Map<String, Object> additionalProperties) Additional generator properties.- Parameters:
additionalProperties
- additional generator properties.- Returns:
- this builder
-
withUseJakartaEe
Flag to indicate whether to use the "jakarta" or "javax" package.- Parameters:
useJakartaEe
- if true, then use the "jakarta" package, otherwise - "javax".- Returns:
- this builder
-
withSortParamsByRequiredFlag
Sort method arguments to place required parameters before optional parameters. Default: true- Parameters:
sortParamsByRequiredFlag
- Sort method arguments to place required parameters before optional parameters- Returns:
- this builder
-
withSkipOperationExample
Skip examples defined in operations to avoid out of memory errors. Default: false- Parameters:
skipOperationExample
- Skip examples defined in operations to avoid out of memory errors.- Returns:
- this builder
-
withSkipSortingOperations
Skip sorting operations. Default: false- Parameters:
skipSortingOperations
- Skip sorting operations- Returns:
- this builder
-
withRemoveOperationIdPrefixDelimiter
MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixDelimiter(String removeOperationIdPrefixDelimiter) Character to use as a delimiter for the prefix. Default: '_'- Parameters:
removeOperationIdPrefixDelimiter
- Character to use as a delimiter for the prefix. Default: '_'- Returns:
- this builder
-
withRemoveOperationIdPrefixCount
MicronautCodeGeneratorOptionsBuilder withRemoveOperationIdPrefixCount(int removeOperationIdPrefixCount) Count of delimiter for the prefix. Use -1 for last Default: 1- Parameters:
removeOperationIdPrefixCount
- Count of delimiter for the prefix. Use -1 for last Default: 1- Returns:
- this builder
-
withSortModelPropertiesByRequiredFlag
MicronautCodeGeneratorOptionsBuilder withSortModelPropertiesByRequiredFlag(boolean sortModelPropertiesByRequiredFlag) Sort model properties to place required parameters before optional parameters.- Parameters:
sortModelPropertiesByRequiredFlag
- Sort model properties to place required parameters before optional parameters.- Returns:
- this builder
-
withEnsureUniqueParams
Whether to ensure parameter names are unique in an operation (rename parameters that are not).- Parameters:
ensureUniqueParams
- Whether to ensure parameter names are unique in an operation (rename parameters that are not).- Returns:
- this builder
-
withAllowUnicodeIdentifiers
boolean, toggles whether Unicode identifiers are allowed in names or not, default is false.- Parameters:
allowUnicodeIdentifiers
- toggles whether Unicode identifiers are allowed in names or not, default is false- Returns:
- this builder
-
withPrependFormOrBodyParameters
MicronautCodeGeneratorOptionsBuilder withPrependFormOrBodyParameters(boolean prependFormOrBodyParameters) Add form or body parameters to the beginning of the parameter list.- Parameters:
prependFormOrBodyParameters
- Add form or body parameters to the beginning of the parameter list.- Returns:
- this builder
-