Skip to content

RestAssured integration

The built-in Mustache templates include RestAssured-based template sets:

  • restassured-java
  • restassured-kotlin

See Template generator for all options.

Gradle example

openApiTestGenerator {
    generator.set("template")
    generatorOptions.putAll(
        mapOf(
            "templateSet" to "restassured-java",
            "templateVariables" to mapOf(
                "package" to "com.example.generated",
                "baseUrl" to "http://localhost:8080",
            ),
        )
    )
}

CLI example

openapi-testgen \
  --spec-file ./openapi.yaml \
  --output-dir ./build/generated-tests \
  --generator template \
  --generator-option templateSet=restassured-java \
  --generator-option templateVariables.package=com.example.generated \
  --generator-option templateVariables.baseUrl=http://localhost:8080

Samples

RestAssured integration

The built-in template generator includes RestAssured-based templates.

Configure base URL

Built-in templates read baseUrl from templateVariables:

CLI

openapi-testgen \
  --spec-file ./openapi.yaml \
  --output-dir ./build/generated-tests \
  --generator template \
  --generator-option templateSet=restassured-java \
  --generator-option templateVariables.baseUrl=http://localhost:8080

Gradle

openApiTestGenerator {
    generator.set("template")
    generatorOptions.putAll(
        mapOf(
            "templateSet" to "restassured-java",
            "templateVariables" to mapOf(
                "baseUrl" to "http://localhost:8080",
            ),
        )
    )
}