Rest Assured Json Schema Validator higher draft version needed

147 views
Skip to first unread message

Allen

unread,
Dec 18, 2020, 9:40:01 AM12/18/20
to REST assured
Hello,

I understand that RestAssured is relying on https://github.com/java-json-tools/json-schema-validator for json schema validation. Currently, the json schema validator library supports draft 4. 

My question is, is there a way or workaround for RestAssured to also support higher draft version of json schema? Like version 6 or version 7. 

When I use a property that is not implemented in draft 4, this is what show in eclipse.


Any help is appreciated.

Thanks.

Allen

Johan Haleby

unread,
Dec 18, 2020, 9:42:24 AM12/18/20
to rest-a...@googlegroups.com
Yes it should definitely be updated. However I don't think the json-schema-validator library that RA is using is supporting anything greater than draft 4. So this would mean a complete rewrite essentially, and I don't have the time to do this :(. 
But you're very welcome to contribute. 

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rest-assured/0a90bacb-7985-4453-a946-51d9b784fa11n%40googlegroups.com.

Allen

unread,
Dec 20, 2020, 8:51:53 PM12/20/20
to REST assured
Hi Johan,

Thanks for your reply. I understand. I'd like to contribute but I dont think i am good enough. :)

Another question if i may. if the response has an array of objects and there is a failure with the schema on the first object in the array, it does not iterate to the next one. Is this the expected behavior? Or I am missing something here? 

I want it to still check the next object so all errors are returned at once. You see in the screenshot. The "response" key is an array of objects. The object has a, b, c keys. There are 2 objects inside the array.

But the error returned is for response[0] only. I want also to see the error for response[1] ....


Thanks.

Message has been deleted
Message has been deleted

Allen

unread,
Dec 20, 2020, 9:28:17 PM12/20/20
to REST assured

Thanks for your reply. I understand. I'd like to contribute but I dont think i am good enough. :)

Another question if i may. if the response has an array of objects and there is a failure with the schema on the first object in the array, it does not iterate to the next one. Is this the expected behavior? Or I am missing something here? 

I want it to still check the next object so all errors are returned at once. You see in the screenshot. The "response" key is an array of objects. The object has a, b, c keys. There are 2 objects inside the array.

But the error returned is for response[0] only. I want also to see the error for response[1] ....


PS. Sorry for the spam. I was trying to upload the image. I just posted a link to the image instead.

Richie Chauhan

unread,
Dec 22, 2020, 10:36:20 AM12/22/20
to REST assured
I just finished a lot of digging around the same issue of supported draft versions of the various Java implementations for JSON schemas. Draft 7 allows for if-then-else conditionals which are very useful. 

It seems networknt supports draft-07 and draft-2019-9 (8). everit supports draft-07. There are others listed that I haven't dug into. https://json-schema.org/implementations.html#validator-java

I love the fact that we can do this ->  response.then().assertThat().body(matchesJsonSchema(new URI("URI")));  

I'm sure there isn't a simple answer to this - How difficult and how much time would it take to replace the underlying library to networknt or everit? 


Reply all
Reply to author
Forward
0 new messages