Baeldung
baeldung.com › home › http client-side › json schema validation with rest-assured
JSON Schema Validation with REST-assured | Baeldung
June 3, 2025 - Validate the JSON response based on a schema using REST-assured.
GitHub
github.com › rest-assured › rest-assured › blob › master › modules › json-schema-validator › src › main › java › io › restassured › module › jsv › JsonSchemaValidator.java
rest-assured/modules/json-schema-validator/src/main/java/io/restassured/module/jsv/JsonSchemaValidator.java at master · rest-assured/rest-assured
* A Hamcrest matcher that can be used to validate that a JSON document matches a given <a href="http://json-schema.org/">JSON schema</a>. * Typical use-case in REST Assured: * <pre> * get("/products").then().assertThat().body(matchesJson...
Author rest-assured
Videos
13:11
REST Assured Beginner Tutorial 10 | How to validate JSON Schema ...
JSON Schema Validation in Rest Assured
12:38
JSON Schema Validation in Rest Assured
12:40
27. JSON Schema Validation using Rest Assured | Step-by-Step Guide ...
15:11
JSON Schema Validation in Rest Assured | API Testing Framework ...
Makeseleniumeasy
makeseleniumeasy.com › 2020 › 10 › 28 › rest-assured-tutorial-55-json-schema-validation-in-rest-assured
REST Assured Tutorial 55 – JSON Schema Validation in Rest Assured
Rest Assured provides support to JSON schema validation since 2.1.0 version. But to use this feature we need to add another Java library “json-schema-validator” in our project classpath.
Maven Repository
mvnrepository.com › artifact › io.rest-assured › json-schema-validator
Maven Repository: io.rest-assured » json-schema-validator
January 16, 2026 - Rest-Assured is a Java library for testing REST services.
Javadoc.io
javadoc.io › doc › io.rest-assured › json-schema-validator › 3.1.1 › io › restassured › module › jsv › JsonSchemaValidator.html
JsonSchemaValidator - json-schema-validator 3.1.1 javadoc
Latest version of io.rest-assured:json-schema-validator · https://javadoc.io/doc/io.rest-assured/json-schema-validator · Current version 3.1.1 · https://javadoc.io/doc/io.rest-assured/json-schema-validator/3.1.1 · package-list path (used for javadoc generation -link option) https://jav...
TutorialsPoint
tutorialspoint.com › validate-json-schema-in-rest-assured
Validate JSON Schema in Rest Assured.
import org.testng.annotations.Test; import static io.restassured.RestAssured.given; import java.io.File; import io.restassured.RestAssured; import io.restassured.module.jsv.JsonSchemaValidator; public class NewTest { @Test public void validateJSONSchema(){ //base URL RestAssured.baseURI = "https://jsonplaceholder.typicode.com/posts/2"; //obtain response given() .when().get() //verify JSON Schema .then().assertThat() .body(JsonSchemaValidator.
Javadoc.io
javadoc.io › doc › io.rest-assured › json-schema-validator › latest › index.html
json-schema-validator 5.5.6 javadoc (io.rest-assured)
Latest version of io.rest-assured:json-schema-validator · https://javadoc.io/doc/io.rest-assured/json-schema-validator · Current version 5.5.6 · https://javadoc.io/doc/io.rest-assured/json-schema-validator/5.5.6 · package-list path (used for javadoc generation -link option) https://jav...
Top answer 1 of 3
2
"pattern": "" means "match everything". Perhaps you meant "const": ""?
Also, if you want to match a four digit number exactly, without permitting any leading or trailing characters, you need to explicitly anchor the pattern: "pattern": "^[0-9]{4}$"
2 of 3
0
Try below schema: json schema validator
I'm using property type for validation for if condition I'm setting type as string with maxLength is zero and for else I'm setting type as number with minimum and maximum properties, You can updated these based on your requirement
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
"courses"
],
"properties": {
"courses": {
"type": "array",
"items": {
"type": "object",
"required": [
"position",
"previous_course_rank",
"location",
"established",
"course_name",
"course_id",
"holes"
],
"properties": {
"position": {
"type": "string"
},
"previous_course_rank": {
"type": "string"
},
"location": {
"type": "string"
},
"course_name": {
"type": "string"
},
"course_id": {
"type": "string"
},
"holes": {
"type": "array",
"items": {
"type": "object",
"required": [
"hole"
],
"properties": {
"hole": {
"type": "string"
}
}
}
}
},
"if": {
"properties": {
"course_id": {
"const": "056"
}
}
},
"then": {
"properties": {
"established": {
"type": "string",
"maxLength": 0
}
}
},
"else": {
"properties": {
"established": {
"type": "number",
"minimum": 1900,
"maximum": 3000
}
}
}
}
}
}
}
GitHub
github.com › osandadeshan › rest-assured-json-schema-validation-demo
GitHub - osandadeshan/rest-assured-json-schema-validation-demo: A demo project to validate a JSON response based on a predefined JSON schema.
June 28, 2017 - public class UserTest { private static final String BASE_URI = "https://gorest.co.in/public-api/"; @Test public void validateUserDetailsJsonSchema() { ValidatableResponse response = given() .contentType(ContentType.JSON) .accept(ContentType.JSON) .baseUri(BASE_URI) .when() .get("users/2") .then(); System.out.println("GET Response:\n" + response.extract().body().asString()); // Verify the status code Assert.assertEquals(response.extract().statusCode(), 200); // Verify the response attributes assertNotNull("'id' should not be null", response.extract().body().jsonPath().get("data.id")); assertNot
Starred by 3 users
Forked by 3 users
Languages Java 100.0% | Java 100.0%
GitHub
github.com › rest-assured › rest-assured › tree › master › modules › json-schema-validator
rest-assured/modules/json-schema-validator at master · rest-assured/rest-assured
Java DSL for easy testing of REST services. Contribute to rest-assured/rest-assured development by creating an account on GitHub.
Author rest-assured
SWTestAcademy
swtestacademy.com › home › json schema validation with rest-assured
JSON Schema Validation with Rest-Assured
December 4, 2018 - In order to do schema validation, you need to add JSON Schema Validator library into your project. You may find the details of the library in this link(https://mvnrepository.com/artifact/io.rest-assured/json-schema-validator/3.0.0).
LinkedIn
linkedin.com › pulse › json-schema-validation-api-testing-using-rest-assured-kumar-jitendra-ohtjc
JSON Schema Validation in API Testing using Rest ...
We cannot provide a description for this page right now
Stack Overflow
stackoverflow.com › questions › 78320565 › json-schema-validation-using-rest-assured-not-able-perform
automation - Json schema validation using Rest assured. not able perform - Stack Overflow
Generate schema online based on your response using this website:https://www.liquid-technologies.com/online-json-to-schema-converter. After that store schema(ResponseSchema.json) in class path and add Json Schema Validator dependency as well. Link:https://mvnrepository.com/artifact/io.rest-assured/json-schema-validator.