Gradle plugin reference¶
Plugin id: art.galushko.openapi-test-generator
Implementation class: art.galushko.openapi.testgen.plugin.OpenApiTestGeneratorPlugin
Adding to an existing project¶
Step 1: Apply the plugin¶
See Version placeholders for how to choose<version>. Step 2: Configure the generator¶
Minimum configuration:
openApiTestGenerator {
specFile.set("src/main/resources/openapi.yaml")
outputDir.set(layout.buildDirectory.dir("generated/openapi-tests"))
generator.set("template") // or "test-suite-writer"
}
Step 3: Add test dependencies¶
For the template generator with RestAssured:
dependencies {
testImplementation("io.rest-assured:rest-assured:5.5.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
}
Step 4: Run in CI¶
Or explicitly:
See CI/CD integration for job wiring patterns.
Extension: openApiTestGenerator¶
Apply and configure:
plugins {
id("art.galushko.openapi-test-generator") version "<version>"
}
openApiTestGenerator {
specFile.set("src/test/resources/openapi.yaml")
outputDir.set(layout.buildDirectory.dir("generated/openapi-tests"))
generator.set("template")
}
Example: configure example value options:
openApiTestGenerator {
testGenerationSettings {
exampleValues.putAll(
mapOf(
"includeOptionalExampleProperties" to true,
"includeWriteOnly" to false,
"useSchemaExampleFallback" to true,
)
)
}
}
Fields¶
configFile: Property<String>(optional): path to YAML config.specFile: Property<String>: path to the OpenAPI spec (relative to project dir or absolute).outputDir: DirectoryProperty: output directory for generated artifacts.generator: Property<String>: generator id (templateortest-suite-writer).generatorOptions: MapProperty<String, Any?>: generator-specific options.testGenerationSettings: TestGenerationSettingsExtension: typed settings DSL (nested block).manualOnly: Property<Boolean>(defaultfalse): disable automatic wiring whentrue.alwaysWriteTests: Property<Boolean>(optional): force writing artifacts even when generation fails.logLevel: Property<String>(optional): log level for generator logs (SLF4J backend).
Nested extension: testGenerationSettings { ... }¶
openApiTestGenerator {
testGenerationSettings {
maxSchemaDepth.set(50)
maxSchemaCombinations.set(100)
maxTestCasesPerOperation.set(1000)
maxErrors.set(100)
errorMode.set(art.galushko.openapi.testgen.model.error.ErrorMode.COLLECT_ALL)
includeOperations.put("/users/{userId}", listOf("GET"))
validSecurityValues.put("ApiKeyAuth", "test-key")
}
}
Fields¶
includeOperations: MapProperty<String, Any>ignoreTestCases: MapProperty<String, Any>ignoreSchemaValidationRules: SetProperty<String>ignoreAuthValidationRules: SetProperty<String>maxSchemaDepth: Property<Int>overrideBasicTestData: MapProperty<String, String>maxSchemaCombinations: Property<Int>maxMergedSchemaDepth: Property<Int>maxTestCasesPerOperation: Property<Int>validSecurityValues: MapProperty<String, String>errorMode: Property<ErrorMode>includeValidCase: Property<Boolean>maxErrors: Property<Int>exampleValues: MapProperty<String, Any>(raw map passed to core)patternGeneration: MapProperty<String, Any>(raw map parsed by pattern support)
includeOperations expects a map of path strings to a list of HTTP methods (e.g., listOf("GET")).
Task: generateOpenApiTests¶
The plugin registers a single task:
- Name:
generateOpenApiTests - Group:
verification
Wiring behavior¶
Wiring depends on generator and manualOnly:
template:- Adds
outputDirto the test source set - Wires compilation (
compileTestJava/compileTestKotlin) to depend on generation whenmanualOnly=false test-suite-writer:- Wires generated files into
processTestResourceswhenmanualOnly=false
See also¶
- Include operations - Target specific operations (recommended)
- Ignore rules - Filter by exclusion
- CI/CD integration - CI job wiring patterns
- Test-suite-writer - JSON/YAML output format
Distribution defaults¶
See Distribution settings for the shared defaults and precedence used by the CLI and Gradle plugin.