openapi-library / OpenAPIValidators

Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
MIT License
190 stars 35 forks source link

Unexpected additional properties analysis #206

Open IvanStawski opened 3 years ago

IvanStawski commented 3 years ago

To Simplify test analisys with

Does it make sense?

rwalle61 commented 3 years ago

Thanks @IvanStawski, what validation error does our plugin currently give when the response object contains additional properties to those described in the OpenAPI response schema?

Have you definitely specified additionalProperties: false in your OpenAPI spec?

additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. Consistent with JSON Schema, additionalProperties defaults to true.

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#schema-object

IvanStawski commented 3 years ago

Thanks @IvanStawski, what validation error does our plugin currently give when the response object contains additional properties to those described in the OpenAPI response schema?

  1. Example of the current validation error given in the current version: https://prnt.sc/vuz8cw. There is no any mention of what field was actually appeared in the response

Have you definitely specified additionalProperties: false in your OpenAPI spec?

  1. Yes, exactly. this is the case. When such unclear validation error appears
rwalle61 commented 3 years ago

Ah thanks @IvanStawski, sorry, I understand now that you'd like the assertion message from a definition using additionalProperties: false to be clearer.

If you'd like to help resolve this, please recreate an example using the bugRecreationTemplate. (I assume you'd like throw to throw an error like https://prnt.sc/viqtti)

IvanStawski commented 3 years ago

please recreate an example using the bugRecreationTemplate

Please clarify: How should I provide an example? Should I make a PR or something else?

rwalle61 commented 3 years ago

Yea please fork this repo and make a branch recreating this scenario in the bugRecreation template (i.e. write a test where we fail to output the assertion error you'd like). Link it here, then someone (or yourself if you want) can make the test pass. I'm happy to guide them on how to implement the change to our code.

Thanks!