-
Notifications
You must be signed in to change notification settings - Fork 115
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
Get json response according to uri parameter value #48
Comments
Hi @suleymanccelik this is currently not possible. Currently Drakov only looks at the key of the query parameter. This is however on our roadmap. We did a refactor of our route handling a short time ago with the view of handling these situations better in the future. I'll do a review of what we need to do to achieve responses based on particular query parameter values and update you in this issue in the next day or so 👍 |
Thanks for reply @yakovkhalinsky . Looking forward this feature. |
I would also love to see this feature. I would like to use it for mocking an API for UI testing and creating screenshots for the App Store. |
+1 is there any way to help? |
The good news is, we are currently doing some work on how parameters are treated, so I would think we could do this sooner rather than later. Will keep this issue updated when we get closer to getting this feature into drakov. 👍 @hendrikmaus PR's are very welcome! Feel free to dive into the code and ask questions 👍 |
Is this supported by the official API blueprint specs? |
@hendrikmaus previous response was wrong ( my head was in another issue :) ) I don't believe this is in the spec as far as I know. |
@hendrikmaus not in the specs but handled by Apiary AFAIK. |
Nice. This is also really neat if you write blueprints to run through dredd for testing besides your main documentation. |
@yakovkhalinsky this issue should be fixed by #87. I think you can close it now. |
@groyoh unfortunately the commit from #87 does not solve this issue. Drakov mock server still can't differentiate the requests with different value for the same query param, at least not using API blueprint file. |
@IvBre doing something like this works: ## Things [/api/query?param1=12345]
+ Parameters
+ param1 (string, `12345`) ... Parameter for the request
### Get with query parameter [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Body
{
"id": "parameter1_12345"
}
## Things [/api/query?param1=12346]
+ Parameters
+ param1 (string, `12346`) ... Parameter for the request
### Get with query parameter [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Body
{
"id": "parameter1_12346"
} |
@groyoh thank you for your suggestion, it seems that it works! Although Dredd is complaining that there is no {param1} defined in the URI template, but its not critical. Thank you! |
@IvBre glad I was able to help. To be clear on this, you are right when saying that this is (was?) not within the specification, but since it worked on Apiary (not sure if it is still the case) I thought than adding it to drakov would be helpful as we also needed it. |
Hi everyone,
How can I achieve to get json response according to uri parameter value? If p is equal to Y, I want to get first json body. But there is no p field in json body. If p is equal to X, I want to get second json body. I am using drakov as mock server. When I start drakov mock server, Both localhost:3000/api.php?p=Y and localhost:3000/api.php?p=X returns first json body.
drakov url : https://www.npmjs.com/package/drakov
GET /api.php?p=Y
Response 200 (application/json)
GET /api.php?p=X
Response 200 (application/json)
The text was updated successfully, but these errors were encountered: