-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "default" and "5XX" types of response status code #226
Comments
Thanks @leonoh-oua! I think we overlooked this functionality. The bug is occuring because we currently throw an error if the actual status code doesn't exactly match that of any responses in the API spec. As you say, if there are no exact matches, instead we should try to match (e.g.) To capture this in tests, we probably want new tests here asserting:
And we may want to update the current error messages thrown when there are no matches, e.g.
What do you think of that error message? Also, if you'd like to contribute a PR, I'm happy to support you with advice or by writing the tests. Let me know :) |
@rwalle61 expected res to satisfy a '400' response defined for endpoint 'POST /x/y' in your API spec
res had status '400', but your API spec has no '400' response defined for endpoint 'POST /x/y'
Response statuses found for endpoint 'POST /x/y' in API spec: 200, 401, 404, 406, 500, 4XX I think your suggested error message is obvious enough! |
I wish I would have time to fix it myself :/ I agree with @setaman . Your suggested error message looks good to me too. |
Which package are you using?
chai-openapi-response-validator
OpenAPI version
3
Describe the bug
Support "default" and "5XX" types of response status code. Those responses are valid based on the open api documents.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responsesObject
https://swagger.io/docs/specification/describing-responses/
OpenAPIValidators doesn't seem to support these responses other than status codes in number.
To Reproduce
Sorry for not having time to provide recreation test case.
In open api spec, add 2 different types of response type, "200" and "default", under
responses
section for whatever path and methodIn a test, call
satisfyApiSpec
with actual response with 400 status codeTest fails with
Expected behavior
The response is supposed to be validated based on the "default" response definition under
responses
Additional context
Reproduce steps above are only about
default
. But I can see that OpenAPIValidators doesn't support status code range such as "5XX" eitherAre you going to resolve the issue?
I'd like you to confirm this is a bug or there's something I'm missing.
The text was updated successfully, but these errors were encountered: