Karate matcher to validate embeded arrays in response

Viewed 19

I have an api response in below format

[ 
   { 
     primaryItem: ' some non null string' , 
     secondaryItems: [
         {
             property_1: 'non Null String',
             property_2: 'non null String'
         },
         .......,
         ........
      ]  
   },
   .......,
   ........
   
]

I want to write a match expression to validate only the structure of data, not the content of data.

I wrote the matcher like below and it works

 ....
 ....
 When method GET
 Then status 200
 And match response != null
 And match each response contains { primaryItem: '#string', secondaryItems: '#array'}

But if I want to validate each secondaryItems structure, what is the best way to do it ?

UPDATE

I believe solution is already documented in karate-schema-validation.

0 Answers
Related