apiaryio / dredd

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

Testing should validate off of MSON Properties as well as schema #498

Closed donbobbo4 closed 7 years ago

donbobbo4 commented 8 years ago

Testing should validate off of MSOM Properties as well as schema. Here is the current rules but think if MSOM properties are defined then it should validate schema. Apiary is already generating a schema based off of these properties.

Expectations There are some automatically-generated expectations on HTTP responses based on examples in the blueprint with the use of Gavel.js library. Please refer to Gavel rules if you want to know more.

Headers Expectations

Body Expectations

honzajavorek commented 8 years ago

@donbobbo4 I'm afraid I don't understand your issue very well. We want to better document it (see https://github.com/apiaryio/dredd/issues/496), but Dredd goes like this:

  1. If response was defined in the API Blueprint with + Schema section containing JSON Schema, then such schema used for validation.
  2. If response was defined in the API Blueprint by example and there's no + Schema section, gavel.js takes the example and checks whether the real response has at least object properties of the same names.
  3. If response was defined in the API Blueprint by + Attributes (a.k.a MSON), then API Blueprint parser generates both example and schema and Dredd uses the generated schema for validation.

As of now validation of headers is done by checking whether all documented headers are present in the real response (i.e. headers with the same names are present). Only values of headers significant for content negotiation are validated also by value.

honzajavorek commented 7 years ago

The behavior was documented (https://github.com/apiaryio/dredd/issues/496) and there's no follow up from @donbobbo4. Closing this for now.