Skip to content

Which module do I need

REST Assured is split into modules. Every test project needs rest-assured. What else you add depends on what your tests do. All modules have the group id io.rest-assured, and they must all have the same version, so keep the versions in line.

rest-assured is the DSL: given(), when() and then(), status codes, headers, cookies, object mapping, authentication, logging and specifications. It brings rest-assured-common, which the other modules share, and http-client-jdk, the default HTTP client.

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>7.0.0-RC1</version>
<scope>test</scope>
</dependency>

rest-assured has no path engine. Add one if your tests use paths:

You use You need
A GPath path on a JSON body, such as body("lotto.lottoId", ..), path(..), extract().path(..) and rootPath(..), or jsonPath() and JsonPath json-path-gpath
A path on an XML or HTML body, or xmlPath(), htmlPath() and XmlPath xml-path-gpath
A JSONPath path on a JSON body, such as body("$.store.book[?(@.price < 10)].title", ..) json-path-jayway
Anything else, such as statusCode(..), headers, cookies, body(containsString(..)), hasXPath(..), JSON Schema validation or as(Greeting.class) Nothing

GPath is the path syntax REST Assured has always used, and the one on the usage pages. json-path-gpath and xml-path-gpath depend on Groovy. json-path-jayway evaluates JSONPath with Jayway JsonPath, for JSON only, and doesn’t need Groovy. With both json-path-gpath and json-path-jayway on the classpath, REST Assured uses GPath unless you pick Jayway. See Path engines in the usage guide and in the release notes.

Before 7.0.0, json-path-gpath and xml-path-gpath were called json-path and xml-path, and rest-assured included them.

Module When
http-client-jdk The default. It sends the requests with the JDK’s java.net.http.HttpClient and needs nothing else. rest-assured depends on it, so you don’t add it yourself
http-client-apache5 When you need what the JDK client can’t do: the Host, Connection or Upgrade headers, NTLM authentication, TLS to the proxy or a Basic proxy login for an HTTPS request. Or when your tests depend on how Apache HttpClient 4 behaved in REST Assured 6, such as the response headers in the order and case the server sent them. It brings Apache HttpClient 5

With http-client-apache5 on the classpath, REST Assured uses it. See Picking the client for how to choose, and The HTTP client for how the two clients differ.

Module For
spring-mock-mvc Testing Spring MVC controllers with RestAssuredMockMvc, see Spring
spring-web-test-client Testing Spring WebFlux controllers with RestAssuredWebTestClient, see Spring
spring-mock-mvc-kotlin-extensions and spring-web-test-client-kotlin-extensions Given { }, When { } and Then { } for the Spring modules in Kotlin, see Kotlin
kotlin-extensions Given { }, When { } and Then { } in Kotlin 2.2 or later, see Kotlin
scala-extensions Given(..), When(..) and Then(..) in Scala 3, see Scala
scala-support Then() instead of then() in Scala 2.13, see Scala
json-schema-validator Validating a JSON body against a JSON Schema, see JSON Schema validation. It brings Jackson 3. For draft-03 schemas, also add com.github.java-json-tools:json-schema-validator, see The java-json-tools validator

The Spring modules are built and tested on Spring Framework 7, and also tested on Spring Framework 6.2 (Spring Boot 3.5).

The Spring modules don’t bring Spring itself, so add spring-test and spring-webmvc or spring-webflux yourself. A Spring Boot project usually has them already. Like rest-assured, the Spring, Kotlin and Scala modules have no path engine, so add one of the path engines if your tests use paths.

Module What it is
rest-assured-bom A BOM that manages the versions of all modules, see Keep the versions in line
rest-assured-all rest-assured-common, json-path-gpath and xml-path-gpath in one jar, for use next to rest-assured. Use it instead of json-path-gpath and xml-path-gpath if they give you split package problems with the Java module system. It depends on Groovy
rest-assured-openrewrite The OpenRewrite recipes that move your code to 7.0. Give it to the OpenRewrite plugin, never add it as a dependency, see Let OpenRewrite do it
json-path and xml-path Relocations to json-path-gpath and xml-path-gpath, so a build that uses the old names keeps working. They’re removed in REST Assured 8.0.0
spring-commons Code that the Spring modules share. They bring it, so you don’t add it yourself

Every REST Assured module must have the same version as rest-assured. Import rest-assured-bom, and then leave the versions out of the REST Assured dependencies.

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-bom</artifactId>
<version>7.0.0-RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path-gpath</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

REST Assured checks that rest-assured-common, the path engines and the HTTP client modules have the same major and minor version as rest-assured, and fails with a message such as:

java.lang.IllegalStateException: io.rest-assured:json-path-gpath 7.0.0 doesn't match REST Assured 7.1.0. Use one version for all REST Assured artifacts, for example by importing io.rest-assured:rest-assured-bom.

A different patch version only logs that message as a warning.

Spring Boot 3 manages REST Assured. Set the rest-assured.version property. Spring Boot 3.5 imports rest-assured-bom at that version, so it applies to every REST Assured module:

<properties>
<rest-assured.version>7.0.0-RC1</rest-assured.version>
</properties>

With Gradle and the Spring dependency management plugin: ext["rest-assured.version"] = "7.0.0-RC1" in build.gradle.kts. Don’t set a version on the REST Assured dependencies themselves, or Spring Boot keeps the other modules on its own version. See Spring Boot 3.

Spring Boot 4 doesn’t manage REST Assured. Import rest-assured-bom as above, or set the version on each REST Assured dependency. See Spring Boot 4.

Tests of a JSON API, with Maven:

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>7.0.0-RC1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path-gpath</artifactId>
<version>7.0.0-RC1</version>
<scope>test</scope>
</dependency>

Tests of an API that answers in JSON and XML, with Gradle:

dependencies {
testImplementation(platform("io.rest-assured:rest-assured-bom:7.0.0-RC1"))
testImplementation("io.rest-assured:rest-assured")
testImplementation("io.rest-assured:json-path-gpath")
testImplementation("io.rest-assured:xml-path-gpath")
}

Spring Boot 4 with MockMvc, with Maven. Import rest-assured-bom as above, then:

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path-gpath</artifactId>
<scope>test</scope>
</dependency>

Kotlin, with Gradle:

dependencies {
testImplementation(platform("io.rest-assured:rest-assured-bom:7.0.0-RC1"))
testImplementation("io.rest-assured:kotlin-extensions")
testImplementation("io.rest-assured:json-path-gpath")
}

spring-mock-mvc and kotlin-extensions bring rest-assured, so you don’t add it yourself.