-
Notifications
You must be signed in to change notification settings - Fork 281
Dredd ignores Request Parameters #395
Comments
@Alexorz Thanks for the example! I think the problem might be that your If you move the ## Coupons Collection [/api/coupons{?pn,pb}]
+ Parameters
+ pn: 1 (optional) - Page number
+ pb: 20 (optional) - Page by
### List All Coupons [GET]
+ Response 200 (application/json)
+ Attributes
+ something
### Create a New Coupon [POST]
+ Request (application/json)
+ Attributes
+ title: `another coupon` (string, required) - title of the coupon
+ something
+ Response 201 (application/json)
+ Attributes
+ something Is this solution of the issue? |
@Alexorz Feel free to re-open this issue if you get back to this and will think that my answer isn't solution to your problem. As of now I consider this as solved. |
Hello @honzajavorek , the dredd testing works fine in your way. But as a document, I think it's more reasonable to put And I saw apiary.io has already read the .apib in the way that I want:
|
@Alexorz Thanks for pointing this out! If Apiary picks your markup as you expect, then there's an inconsistency and I should look into it - if it's not a bug, then at least to find out reasoning behind it so I'm able to answer here. Possibly related issues: apiaryio/api-blueprint#277, apiaryio/api-blueprint#58 (Note for myself, I need to verify this.) I'll try to get to this soon and verify the behavior, but I can't promise you any ETA now. However, thank you again for sharing this. This may be a valid bug report either for Dredd or Apiary! |
Future versions of API Blueprint allow you to attach parameters to requests, as per RFC 4: Request Parameters. The last pre release of Drafter and Protagonist provide a partial implementation of this feature, however semantic validation around these parameters is not yet complete. I'd say this isn't a bug in either Dredd or Apiary, they are just lacking this feature. I believe #388 is around adding support for this in Dredd. |
@kylef Yes, thanks for providing all the details! I thought this is the case and that was my reasoning why Dredd doesn't work well with this and the API Blueprint needs to be written in a different way. However, as @Alexorz explained on screenshots, Apiary is somehow able to support his syntax. And that's what surprised me and I wanted to explore that a bit deeper and learn how is that possible. |
@honzajavorek From the screenshot, you can see this document is being rendered with the attributes kit feature flag, which means it's using the latest pre-release of the parser which adds partial support for parsing these parameters. However they are not rendered in Apiary documentation or utilised in the Apiary mock server since they haven't adopted this feature yet. @Alexorz I'd recommend you stick to using the resource or action level parameters until we've finalised the support otherwise the information will be missing in your documentation at Apiary and not utilised in Dredd. |
Ah! I didn't realise that. Thanks for spotting, now that all makes perfect sense. @Alexorz Apiary with the attributes kit feature flag turned on is a bit ahead than Dredd and you've ran into a beta feature being under development. @kylef thanks again for bringing light into this. I'm turning this issue into a request for improvement - we should eventually catch up with RFC 4: Request Parameters and make sure it's properly supported in Dredd once it's fully present in Drafter. |
Cool! Looking forward to a better dredd and API Blueprint. |
Any updates on this? :) |
I think this was actually supported since Dredd 1.1.0. I tested this in apiaryio/api-blueprint#58 (comment), where you can find an example. |
I can confirm it is experimentally supported since Drafter supports it to some extent. Not sure how complete the implementation in Drafter is at the moment. Dredd should be ready to inherit the parameters correctly, but there might be other little things needed to be done. The feature wasn't ever discussed yet in its entirety as a Dredd feature, with all the corner cases. Also it is not tested nor documented yet. |
Just a reminder, once this is going to be closed, #88 should be closed, too. |
@kylef What's the status of request parameters in Drafter? Is it finalized? |
@honzajavorek It's supported, but validation is not implemented fully. Nothing has changed since apiaryio/api-blueprint#58 (comment) |
I'm still having this issue. Below is an example spec that can be used to reproduce:
Drakov runs the server and picks up two routes:
But Dredd, complains about ambiguous parameter and completely ignores POST:
Apiary editor picks parameters just fine only for GET. @honzajavorek @kylef any suggestions other than moving parameters one level up (which I'd like to avoid since it makes API spec less clear) |
@gustaff-weldon How about the following: ## Gists Collection [/gists]
### List All Gists [GET /gists{?since}]
+ Parameters
+ since: `2016-12-30T10:00:00Z` (string, optional) - Timestamp in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ` Only gists updated at or after this time are returned.
+ Response 204
### Create a Gist [POST]
+ Request (application/json)
+ Attributes
+ descripton: `sth sth` (string, required)
+ content: `here goess content` (string, required)
+ Response 201 (application/json) |
@kylef cool, I think moving parameter down to |
Even though it's not an officially rolled-out feature in API Blueprint and Apiary, the parser supports request parameters for a long time already and Dredd does as well. Please open other issues if you find the behavior buggy. Closing this in favor of #1118. |
Hi there,
I got a trouble when running dredd (v1.0.5), and it seems to be an issue, here is my apib file:
Here is the result:
The POST request was been ignored when running dredd, because I didn't assign any parameters for this. But actually there is no need to pass any URL parameters for this POST.
So, am I doing right?
The text was updated successfully, but these errors were encountered: