This is a follow up of a question noted here
Lets says our implemented server v1 and v2 response looks as follows
v1Response = { id: \"1\", name: \"a
For some reason you feel that hacking the match
clause is the only way to solve this problem. Please keep an open mind and, here you go:
* def schemas =
"""
{
v1: { id: "#string", name: "#string" },
v2: { id: "#string", name: "#string", value: "#string" }
}
"""
* def env = 'v1'
* def response = { id: "1", name: "awesome" }
* match response == schemas[env]
* def env = 'v2'
* def response = { id: "2", name: "awesome", value: "karate" }
* match response == schemas[env]
* def response = { id: "1", name: "awesome" }
* match response == karate.filterKeys(schemas[env], response)
The last line is as generic as you can get.