我有一个 post API,我希望使用 JsonSchemaValidator 的方法,因为我希望通过执行断言来验证整个响应而不是选择响应
我试过用
- matchesJsonSchemaInClasspath("我的文件名") 和
- matchJsonSchema(我的文件对象)
我的 reposne 即将成为现实,方法正在通过,但我的架构文件没有检查或验证
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))
我尝试使用 jsonSchemaFactory 来执行此操作,但我没有得到关于设置为 draftversion 的内容或从哪里获取它
我是新手,如果你觉得这个问题太简单了,请多多包涵