Class OpenApiGeneratorGenerateExtension

  • All Implemented Interfaces:

    
    public class OpenApiGeneratorGenerateExtension
    
                        

    Gradle project level extension object definition for the generate task

    Author:

    Jim Schubert

    • Constructor Detail

      • OpenApiGeneratorGenerateExtension

        OpenApiGeneratorGenerateExtension(Project project)
    • Method Detail

      • getQuiet

         final Property<Boolean> getQuiet()

        Whether generation should run in quiet mode.

      • getValidateSpec

         final Property<Boolean> getValidateSpec()

        Whether an input specification should be validated upon generation. Defaults to true.

      • getGeneratorName

         final Property<String> getGeneratorName()

        The name of the generator which will handle codegen. (see "openApiGenerators" task)

      • getOutputDir

         final DirectoryProperty getOutputDir()

        The output target directory into which code will be generated.

      • getInputSpec

         final RegularFileProperty getInputSpec()

        The Open API 2.0/3.x specification location.

        Be default, Gradle will treat the openApiGenerate task as up-to-date based only on this file, regardless of changes to any $ref referenced files. Use the inputSpecRootDirectory property to have Gradle track changes to an entire directory of spec files.

      • getInputSpecRootDirectory

         final DirectoryProperty getInputSpecRootDirectory()

        Local root folder with spec files.

        By default, a merged spec file will be generated based on the contents of the directory. To disable this, set the inputSpecRootDirectorySkipMerge property.

      • getMergeMode

         final Property<String> getMergeMode()

        How multiple spec files are merged. Accepted values: "REF" (default, original $ref-based shallow merge, backward-compatible) or "DEEP" (full inline merge with component deduplication and conflict detection).

      • getMergeConflictStrategy

         final Property<String> getMergeConflictStrategy()

        Strategy when two specs define the same component name or path+method with conflicting (non-identical) definitions. Accepted values: "WARN" (default, keep first definition and log a warning) or "FAIL" (throw an exception and abort the build). Only applies when mergeMode is "DEEP".

      • getRemoteInputSpec

         final Property<String> getRemoteInputSpec()

        The remote Open API 2.0/3.x specification URL location.

      • getTemplateDir

         final DirectoryProperty getTemplateDir()

        The template directory holding a custom template.

      • getTemplateResourcePath

         final Property<String> getTemplateResourcePath()

        The template location (which may be a directory or a classpath location) holding custom templates.

      • getAuth

         final Property<String> getAuth()

        Adds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values

      • getConfigFile

         final RegularFileProperty getConfigFile()

        Path to json configuration file. File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...} Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.

      • getSkipOverwrite

         final Property<Boolean> getSkipOverwrite()

        Specifies if the existing files should be overwritten during the generation.

      • getPackageName

         final Property<String> getPackageName()

        Package for generated classes (where supported)

      • getModelNamePrefix

         final Property<String> getModelNamePrefix()

        Prefix that will be prepended to all model names. Default is the empty string.

      • getModelNameSuffix

         final Property<String> getModelNameSuffix()

        Suffix that will be appended to all model names. Default is the empty string.

      • getApiNameSuffix

         final Property<String> getApiNameSuffix()

        Suffix that will be appended to all api names. Default is the empty string.

      • getTypeMappings

         final MapProperty<String, String> getTypeMappings()

        Sets mappings between OpenAPI spec types and generated code types.

      • getServerVariables

         final MapProperty<String, String> getServerVariables()

        Sets server variable for server URL template substitution, in the format of name=value,name=value.

      • getLanguageSpecificPrimitives

         final ListProperty<String> getLanguageSpecificPrimitives()

        Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.

      • getOpenapiGeneratorIgnoreList

         final ListProperty<String> getOpenapiGeneratorIgnoreList()

        Specifies .openapi-generator-ignore list in the form of relative/path/to/file1,relative/path/to/file2. For example: README.md,pom.xml.

      • getImportMappings

         final MapProperty<String, String> getImportMappings()

        Specifies mappings between a given class and the import that should be used for that class.

      • getForcedGenerateSchemas

         final ListProperty<String> getForcedGenerateSchemas()

        Specifies schema names that must be generated even when listed in schemaMappings or importMappings

      • getInlineSchemaOptions

         final MapProperty<String, String> getInlineSchemaOptions()

        Key/value options controlling how inline schemas are handled during generation.

        Common keys: RESOLVE_INLINE_ENUMS (promote inline enums to top-level models), ARRAY_ITEMS_SUFFIX, MAP_ITEMS_SUFFIX. Run config-help -g {generatorName} for the full list of supported options.

      • getOpenapiNormalizer

         final MapProperty<String, String> getOpenapiNormalizer()

        Key/value rules passed to the OpenAPI normalizer, which pre-processes the parsed spec before code generation begins.

        Example rules: REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true, REMOVE_ANYOF_ONEOF_AND_KEEP_PROPERTIES_ONLY=true. See the OpenAPI Generator docs for the full list of normalizer rules.

      • getGroupId

         final Property<String> getGroupId()

        GroupId in generated pom.xml/build.gradle.kts or other build script. Language-specific conversions occur in non-jvm generators.

      • getId

         final Property<String> getId()

        ArtifactId in generated pom.xml/build.gradle.kts or other build script. Language-specific conversions occur in non-jvm generators.

      • getVersion

         final Property<String> getVersion()

        Artifact version in generated pom.xml/build.gradle.kts or other build script. Language-specific conversions occur in non-jvm generators.

      • getLibrary

         final Property<String> getLibrary()

        Reference the library template (sub-template) of a generator.

      • getHttpUserAgent

         final Property<String> getHttpUserAgent()

        HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'

      • getIgnoreFileOverride

         final RegularFileProperty getIgnoreFileOverride()

        Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.

      • getSupportingFilesConstrainedTo

         final ListProperty<String> getSupportingFilesConstrainedTo()

        Defines which supporting files should be generated. This allows you to create a subset of generated files (or none at all).

        Supporting files are those related to projects/frameworks which may be modified by consumers.

        NOTE: Configuring any one of apiFilesConstrainedTo, modelFilesConstrainedTo, or supportingFilesConstrainedTo results in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation. For more control over generation of individual files, configure an ignore file and refer to it via ignoreFileOverride.

      • getGenerateModelTests

         final Property<Boolean> getGenerateModelTests()

        Defines whether model-related test files should be generated.

        This option enables/disables generation of ALL model-related test files.

        For more control over generation of individual files, configure an ignore file and refer to it via ignoreFileOverride. Defaults to true.

      • getGenerateModelDocumentation

         final Property<Boolean> getGenerateModelDocumentation()

        Defines whether model-related documentation files should be generated.

        This option enables/disables generation of ALL model-related documentation files.

        For more control over generation of individual files, configure an ignore file and refer to it via ignoreFileOverride. Defaults to true.

      • getGenerateApiTests

         final Property<Boolean> getGenerateApiTests()

        Defines whether api-related test files should be generated.

        This option enables/disables generation of ALL api-related test files.

        For more control over generation of individual files, configure an ignore file and refer to it via ignoreFileOverride. Defaults to true.

      • getGenerateApiDocumentation

         final Property<Boolean> getGenerateApiDocumentation()

        Defines whether api-related documentation files should be generated.

        This option enables/disables generation of ALL api-related documentation files.

        For more control over generation of individual files, configure an ignore file and refer to it via ignoreFileOverride. Defaults to true.

      • getLogToStderr

         final Property<Boolean> getLogToStderr()

        To write all log messages (not just errors) to STDERR. Defaults to false.

      • getEnablePostProcessFile

         final Property<Boolean> getEnablePostProcessFile()

        To enable the file post-processing hook. This enables executing an external post-processor (usually a linter program). This only enables the post-processor. To define the post-processing command, define an environment variable such as LANG_POST_PROCESS_FILE (e.g. GO_POST_PROCESS_FILE, SCALA_POST_PROCESS_FILE). Please open an issue if your target generator does not support this functionality. Defaults to false.

      • getSkipValidateSpec

         final Property<Boolean> getSkipValidateSpec()

        To skip spec validation. When true, we will skip the default behavior of validating a spec before generation. Defaults to false.

      • getGenerateAliasAsModel

         final Property<Boolean> getGenerateAliasAsModel()

        To generate alias (array, list, map) as model. When false, top-level objects defined as array, list, or map will result in those definitions generated as top-level Array-of-items, List-of-items, Map-of-items definitions. When true, A model representation either containing or extending the array,list,map (depending on specific generator implementation) will be generated. Defaults to false.

      • getEngine

         final Property<String> getEngine()

        Templating engine: "mustache" (default) or "handlebars" (beta)

      • getCleanupOutput

         final Property<Boolean> getCleanupOutput()

        Defines whether the output dir should be cleaned up before generating the output. Defaults to false.

      • getDryRun

         final Property<Boolean> getDryRun()

        Defines whether the generator should run in dry-run mode. Defaults to false.

      • getStrictSpec

         final Property<Boolean> getStrictSpec()

        When true, applies strict validation against the OpenAPI specification, failing on any deviation. When not set, any value from configFile is used; the generator's own default is false.

      • getMinimalUpdate

         final Property<Boolean> getMinimalUpdate()

        When true, only writes output files that have changed relative to an existing generated output. Reduces unnecessary file churn in version control. When not set, any value from configFile is used; the generator's own default is false.

      • getGenerateRecursiveDependentModels

         final Property<Boolean> getGenerateRecursiveDependentModels()

        When true, recursively generates all models that the selected models depend on, even if those dependent models were not explicitly listed for generation. Only relevant when modelFilesConstrainedTo is configured. When not set, any value from configFile is used; the generator's own default is false.

      • getWorkerIsolation

         final Property<String> getWorkerIsolation()

        Controls how the code generation worker is isolated from the Gradle daemon.

        • "classloader" (default): runs inside the Gradle daemon JVM with a separate ClassLoader. No process startup overhead, but generator classes accumulate in daemon Metaspace. Suitable for projects with very few generation tasks.

        • "process": runs in a separate JVM. Metaspace is isolated from the daemon and freed when the worker exits. Gradle reuses the worker process across tasks that share the same classpath, so the JVM startup cost is typically paid only once per parallel slot. Best for projects with many generation tasks.

      • getMaxWorkerHeapSize

         final Property<String> getMaxWorkerHeapSize()

        Maximum heap size for the worker process when workerIsolation is "process" (e.g. "512m", "1g"). Has no effect when workerIsolation is "classloader". When not set, the JVM uses ergonomic defaults (typically based on available system memory). Only set this if you hit OutOfMemoryError during generation of unusually large specs.

      • set

         final Unit set(RegularFileProperty $self, String path)

        Extension function to allow setting inputSpec with a String path in Kotlin DSL. Example: inputSpec.set("$rootDir/api.yaml")

      • set

         final Unit set(DirectoryProperty $self, String path)

        Extension function to allow setting directory properties with a String path in Kotlin DSL. Example: outputDir.set("$buildDir/generated")