Skip to content
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

Testing resources with optional parameters #88

Closed
imp-partner-test opened this issue Aug 4, 2014 · 9 comments
Closed

Testing resources with optional parameters #88

imp-partner-test opened this issue Aug 4, 2014 · 9 comments

Comments

@imp-partner-test
Copy link

How do I test optional parameters?
----Sample URL----
Resources/CarSharing/All?lat={lat}&lng={lng}&radius={radius}
----Parameters description----

  • Parameters
    • lat (optional, string, 52.52) ... String lat latitude value. Has example value.
    • lng (optional, string, 13.39) ... String lng longitude value. Has example value.
    • radius (optional, string, 1000) ... String radius longitude value. Has example value.

I would like to check at least 2 cases: 1) a call with parameters and their sample values and 2) a call without any parameters:

  1. Resources/CarSharing/All?lat=52.52&lng=13.39&radius=1000
  2. Resources/CarSharing/All

Thank you!

@netmilk
Copy link
Contributor

netmilk commented Aug 5, 2014

Thank you for interesting use case, but t this moment there is no way how to prevent parameter substitution. When parameter is defined, example value is always used in the request, even if parameter is optional.

@netmilk
Copy link
Contributor

netmilk commented Jan 15, 2015

Just a little update:
You can specify two different examples (implicit requests and response pairs for the same action, and then modify request parameters in the before hook very similar way as in this example.

More straightforward syntax for this is discussed also in API Blueprint project: apiaryio/api-blueprint#132 apiaryio/api-blueprint#58 (comment)

@netmilk
Copy link
Contributor

netmilk commented May 21, 2015

This is blocked by support for Parameters under each Request secction in the API blueprint apiaryio/api-blueprint#58

At this moment, as a workaround, you can change the request URI in the before hook and describe used parameters in the Request description section.

@hendrikmaus
Copy link

👍

1 similar comment
@hueter
Copy link

hueter commented Jun 22, 2016

+1

@pakore
Copy link

pakore commented May 29, 2018

+1. 4 years since this and it's a pretty basic functionality IMHO...

@honzajavorek
Copy link
Contributor

honzajavorek commented May 29, 2018

@pakore

This is blocked by support for Parameters under each Request secction in the API Blueprint apiaryio/api-blueprint#58

The implementation in the API Blueprint format still isn't in general availability. Please express your feelings under the linked issue. Dredd isn't in a position it could easily overcome the problem, as it is a limitation of the format.

Also, note there are workarounds in the comments above.

@honzajavorek
Copy link
Contributor

@pakore I'm sorry, I did not notice the issue is locked. My apologies. It is the first thing on the public roadmap though.

@honzajavorek
Copy link
Contributor

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.

artem-zakharchenko pushed a commit that referenced this issue Oct 9, 2019
Upgrade minim, fury.js, and fury adapters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants