-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Provide a means for defining erred responses #134
Comments
@nbibler Can you please elaborate a bit? The use case and perhaps a snippet of possible syntax would be great! Thanks |
I would think this refers to the error code they will receive. If a user passes in an invalid value, will they get a 400? 404? Some examples from Spree Commerce: Not Found
Authorization Failure
Invalid API Key
They also return 422 when things can't process. Being able to include these in the documentation can be very helpful. |
You can always write these in the description section of the API. Or do you want to add these when describing every action? |
Here is an example api blueprint which adds the error descriptions and other stuff in API description section. |
hey @MisinformedDNA Would something like this work for you?
|
hey @zdne & @pksunkara , The resource model above looks like the start of something that might work, though I see you combined the 401 responses. It would be a shame if an API had to limit it's ability to return different error messages for a 401 response just because the documentation tool didn't support it. Obviously, the API could diverge, but that's not really the goal. So we should be able to define certain requests that lead to certain error responses. So if the header is missing, the response should be able to give one error message. And if the parameter is the wrong type, a different error message and if the parameter leads to a resource that does not exist, another error. Similar to how we can specify different content-types and get different responses. The goal is to be able to do testing with the docs, right? So we should want and be able to do negative testing as well. I'm still very new here, so if I'm missing anything, I do apologize. But this looked like an interesting issue that I didn't see covered in the docs. |
Would it not make sense to have this tied into the Trait #47 system in someway? Such that if I apply the Trait "Protected" one possible response to the endpoint becomes the Authorization Failure response, if defined with the Trait. |
Along the lines of #132, it would be useful to identify important or interesting error responses in a blueprint.
The text was updated successfully, but these errors were encountered: