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
Do not error when there is no response content but accept header is set #2266
Comments
7 tasks
chohmann
changed the title
[Feature Request] option to not error when there is no response content but accept header is set
Do not error when there is no response content but accept header is set
Apr 21, 2023
@jedwards1211 thank you for reporting this. We don't think this is a feature request, but rather a bug. So rather than being able to configure whether we throw in this scenario, we think we should never throw in this scenario. Here's what we think the behavior should be:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
We would like to be able to mock test a customer's method that they're asking us to call with
accept: application/json
even though the method doesn't respond with a body. Their OpenAPI spec for the method hasCurrent Behavior
If we make the request to
prism mock
withaccept: application/json
, it complains that it doesn't know what responsebody to produce:
[4:17:15 PM] › [HTTP SERVER] delete /responder_endpoints ✔ success Request received
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < Headers:
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < accept: application/json
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < accept-encoding: gzip,deflate
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < host: 127.0.0.1:4010
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < connection: keep-alive
[4:17:15 PM] › [NEGOTIATOR] ⬤ debug < Body:
[4:17:15 PM] › [NEGOTIATOR] ✔ success Request contains an accept header: application/json
[4:17:15 PM] › [VALIDATOR] ✔ success The request passed the validation rules. Looking for the best response
[4:17:15 PM] › [NEGOTIATOR] ⚠ warning Unable to find content for application/json
[4:17:15 PM] › [HTTP SERVER] delete /responder_endpoints ✖ error Request terminated with error: https://stoplight.io/prism/errors#NOT_ACCEPTABLE: The server cannot produce a representation for your accept header
Expected Behavior
We have some way to suppress this error, making
prism mock
respond with 200 and no body.Possible Solution(s)
It would be nice to have a
--no-accept-void-response-error
CLI flag to suppress this error.The text was updated successfully, but these errors were encountered: