I have a post API , i want methods of JsonSchemaValidator to be used as I want the whole reponse to be validated rather than selected reponse by performing assertion
I have tried to use
- matchesJsonSchemaInClasspath("my file name") and
- matchesJsonSchema(my file object)
my reposne is coming to be true, method is getting passed but there is no checking or validation with my schema file
public void directLoginWihSchemaValiadtor(){
File file = new File("C:/Users/abeey/git/SlingAppWebService/Configurations/JsonSchemaValidator_DirectLogin_AWS.json");
jsonasmap.put("contactNo", "some number");
jsonasmap.put("loginType","0");
jsonasmap.put("appid","2");
jsonasmap.put("co*****ode","IN");
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder().
setValidationConfiguration(ValidationConfiguration.newBuilder().freeze()).freeze();
given().contentType(ContentType.JSON).body(jsonasmap).when().
post("https://60i*****.execute-api.us-west-2.amazonaws.com/some-api").
then().assertThat().
body(JsonSchemaValidator.matchesJsonSchema(file))).
log().all();
jsonasmap.clear();
}
//body(JsonSchemaValidator.matchesJsonSchemaInClasspath("JsonSchemaValidator_DirectLogin_AWS.json").using(jsonSchemaFactory))
I tried to use jsonSchemaFactory to do this but i didnt get that either on what to set as the draftversion or from where to get it
I am new to this , please bear with me if you found this question too simple to be asked