cygne
cygne

Reputation: 547

how to validate an array in json response karate framework

In the example bellow if warehouse is an array, how I can validate a json response like in this example:

Scenario: using karate's simpler alternative to json-schema
* def warehouseLocation = { latitude: '#number', longitude: '#number' }
* def productStructure =
"""
{
 id: '#number',
 name: '#string',
 price: '#number? _ > 0',
 tags: '##[_ > 0] #string',
   dimensions: {
     length: '#number',
     width: '#number',
     height: '#number'
   },
 warehouseLocation: '##(warehouseLocation)'
}
"""
* def json = read('products.json')
* match json == '#[] productStructure'

Where I have ti put #array. I've tried different issues, but it doesn't work. Thanks

Upvotes: 1

Views: 1235

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

Your question is asking for warehouse which I can't find at all in your example. I assume you are asking for this:

warehouseLocation: '#[] warehouseLocation'

Upvotes: 1

Related Questions