Closed ido567 closed 6 years ago
Hi, this is described in the docs as the Making Dredd Validation Stricter section. Would the suggestions in the section solve this for you?
Didn't test it yet, but it looks like what I'm trying to achieve. Is there a way to configure it globally? Or by a hook?
It is a sort of limitation/feature of the API description format. The transaction object you get in the hooks has transaction.expected.bodySchema
, where you can find the JSON Schema. In a beforeAll
or beforeEach
hook, you could go and make the schema stricter by appending "additionalProperties": false
(ref) wherever you like (recursively?).
Sound like recursion is the only option. Do you have an example of a recursive function that adds some properties to every expected schema?
I don't know about anything from the top of my head, but try to check out the examples in the sanitation docs.
OK, I'll check it out. Thank you so much for the help!!
You're welcome! Thank you for using Dredd!
Describe your problem
I'm not sure if it's a bug, a configuration problem, or by design - Dredd doesn't fail if the response contains additional structure than described in my swagger.
My Swagger:
The response:
Is Dredd designed for that? If so, how can I achieve this behavior by hooks?
What command line options do you use?
What is in your
dredd.yml
?What's your
dredd --version
output?Does
dredd --level=debug
uncover something?Not sure, here is the output:
Can you send us failing test in a Pull Request?
In my case, the problem is that the test doesn't fail :)