Trax-air/swagger-tester

when should default response be checked?

Closed this issue · 2 comments

Specifically I have a question on this conditional:

if 'default' not in response_spec.keys():
    assert response.status_code in response_spec.keys()
    validate_definition(swagger_parser, response_spec[response.status_code], response_json)
else:
    validate_definition(swagger_parser, response_spec['default'], response_json)

From what I understand, if there is a default key in the Responses object then swagger_tester will ALWAYS validate the default response object, and only validate specific status codes when there is no default. So if there is both a 200 & default response, then the 200 will never be validated. is this desired? I feel like the default should only be validated when the response code does not match one within the response object.

What's the justification for this? is it desired?

To be honest I don't remember why it has been done this way... But I am completely agree with you on this. I can fix this tomorrow, or you can submit a PR.

Fixed and deployed in v0.2.4 😄