apiaryio / gavel2html

Renders HTML diff from Gavel.js output
MIT License
0 stars 0 forks source link

Valid body doesn't get diff of added properties #23

Open artem-zakharchenko opened 5 years ago

artem-zakharchenko commented 5 years ago

Scenario

Whenever a body field is valid, even if an actual field has additional properties, those properties are not highlighted as added.

{
  "expected": { "login": "admin" },
  "actual": { "login": "joe", "newProp": true }
}

The newProp property won't be shown as the added one (green).

Expected behavior

Any property that is present in the actual HTTP message field (i.e. body, headers), but is not specified in the expected HTTP message field must be highlighted as the added one.

artem-zakharchenko commented 5 years ago

To clarify: if a body is invalid (i.e. there is a missing property in the actual body), then the new properties are highlighted as green. At first glance it looks like gavel2html skips the diff is a field is valid.

artem-zakharchenko commented 5 years ago

Here's the cause in the source code:

https://github.com/apiaryio/gavel2html/blob/99897d716d44c85997399f6bb4ef8c9450cfbf26/src/json-result-converter.coffee#L185-L188

Even the comment suggest there will be an issue, since the diff'ing is skipped when there are no errors.