我正在使用 Spring Boot 和 REST Assured 来测试 REST API。我正在尝试使用 JSON 模式验证的示例,但它抛出了这个错误:
java.lang.IllegalArgumentException: Schema to use cannot be null
根据文档,架构应该位于 classpath 中。我的示例架构位于那里。这是我的项目结构和示例架构位置:
这是我的代码。如果没有模式验证,它可以正常工作。
given().
contentType("application/json").
when().
get("http://myExample/users").
then().
assertThat().body(matchesJsonSchemaInClasspath("example_schema.json"));