apiaryio / dredd

Language-agnostic HTTP API Testing Tool
https://dredd.org
MIT License
4.18k stars 279 forks source link

Validating inside arrays #690

Closed Heanthor closed 7 years ago

Heanthor commented 7 years ago

I'm frustrated by dredd's inability to validate inside JSON arrays. My API response has the following layout:

{
   "code": 200,
   "status": "success",
   "data": [
      {
         "id": "xxx",
         "type": "xxx",
         "title": "xxx"
      }]
   }
}

which dredd validates by checking if "code", "status", and "data" are present. I cannot find any way to make gavel validate the contents of the "data" array. Is the only option to write custom hooks and do the work myself?

honzajavorek commented 7 years ago

@Heanthor Unfortunately, yes, at the moment. This is a known issue:

As a workaround, you can:

I hope this helps!

adityasaxena commented 7 years ago

@honzajavorek It would help if you could provide an example of the test you mention. The documentation your link points to contains nothing useful I believe

honzajavorek commented 7 years ago

@adityasaxena You mean the + Schema mention?

honzajavorek commented 7 years ago

@adityasaxena I've added an example to the specification: https://github.com/apiaryio/api-blueprint/pull/385