-
Notifications
You must be signed in to change notification settings - Fork 280
Dredd unable to correctly handle blueprint with multiple requests #78
Comments
Thanks for the report! Can you provide here raw blueprint for replicating the issue? |
Sure, here: https://github.com/apiaryio/apiblueprintorg/blob/master/apiary.apib
|
Ok, this is verified. But what's the proposed behaviour? Should Dredd test the response for each request? $ curl -s https://raw.githubusercontent.com/apiaryio/apiblueprintorg/master/apiary.apib > multi-blueprint.md |
As there can be multiple requests as well as multiple responses, I think the algorithm would be following (high-level coffee-like pseudocode): for example in examples
for request in example.requests
for response in example.responses
test(request, response) That's probably the best |
Maybe I'm not right, but I don't think so. This code will mean that in the example if there is no request but only responses, no test is created and also if there is no response only request no test is created either. |
Well, yes, good catch. I did not think about these cases while writing the code. Depends on what is the intended behavior, what the blueprint author expects in such situation - one option is to skip cases where the pair is not complete (code above) or to provide a default request and default response: for example in examples
for request in (example.requests or [defaultRequest])
for response in (example.responses or [defaultResponse])
test(request, response) Right now I don't know what's Apiary app's behavior in these cases and if there's a concept of default request/response already. I'd need to experiment with it for a while. |
poke This issue is coming up for me now, any progress? |
Hi @obihann this hasn't been addressed yet, next week we'll be able to give you some ETA. |
@w-vi If this is a manpower issue let me know I can likely help out. Thanks for the reply though. |
Hey @obihann, thank you very much for offering help! It's awesome! Would you be so kind and share a blueprint example with multiple request and responses and proposed test matrix for these examples and request -response pairs? |
No problem, I'll have that for you later today. |
### Delete a Object [DELETE /{id}{?permanent}]
+ Parameters
+ permanent: `0` (number, optional) - Set if the object will be permanently deleted
+ Members
+ `0` - Flag the object as deleted however do not remove it from our system
+ `1` - Permanently delete this object
+ Request
+ Response 202 So this is an example of some markdown I have, it represents a single API endpoint that accepts an optional URL param that can be either An alternative solution that may required updates to the MSON spec would be a way to outline what URL param values are includes in each request. |
Another use case would be two request's one with a body one without, the one without would return something like a 400, perhaps with a explicit error. The request with a body would return something like a 200. The point here being to test that invalid requests do not break (500) the server and are handled properly. |
This is biting me again as well as #25. The use case is pretty much the same as before - I am working on similar parsing service as in my previous comments. It uses multiple requests and responses (M:N relation) heavily. I can not use Dredd for testing such API as it always takes just the first pair. |
This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615 BREAKING CHANGE
This change fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement apiaryio/dredd#25 and apiaryio/dredd#78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd apiaryio/dredd#227. BREAKING CHANGE
This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615 BREAKING CHANGE
BREAKING CHANGE: This change tests and fixes a problem introduced with migration to API Elements in order to support Swagger in Dredd. Original implementation always selected the first request-response pair from each transaction example. This wasn't re-implemented correctly on top of API Elements. Instead, all specified responses are appearing, which breaks Dredd's behavior in many ways. Respective test was ported, but unfortunately with the same mistake. This commit fixes the situation. Some early adopters discovered the issue and considered it to be a new feature, but it really breaks how Dredd should work at the moment and needs to be removed. It leads to duplicate transaction names and other undefined behavior. In order to implement #25 and #78, which many believed happened when they discovered the bug, much more work needs to be done. Namely designing and adopting a new way of addressing transactions in Dredd #227. Closes #615
Since we have moved to API Description Refract, we can support this in a backward compatible way. Assume, we have request response pairs (RRP from now) in an API Blueprint as shown below:
API Description refract generates 5 RRP. They are as follows:
Actual BehaviourDredd currently only tests Expected BehaviourDredd needs to test all 5 pairs. But to ensure the backward compatibility of the order of the pairs that are being tested, we will add the newer pairs to the end. Which means dredd will test them in the following order: |
@pksunkara As we discussed previously, I think adding new transactions is still a breaking change, but that could be solved. We could either make this breaking change, or to skip the transactions by default and allow people to unskip them in hooks. And when I was thinking about writing you the sentence above, I just realized a problem with this. What would be transaction names of the added requests? There is no way how to distinguish such transactions in current transaction names. According to how it works now, the transaction names would be:
That's it. They wouldn't be addressable. So I'm really afraid this will be possible only after #227 are done 😞 |
The transaction names would be:
I thought that part was clear from my comment. |
Example blueprint: http://docs.apiblueprintapi.apiary.io/ Possibly related to #25.
The text was updated successfully, but these errors were encountered: