2

What I'm trying to do with an API-blueprint (with dredd as testrunner) is calling a backend twice in a row with almost the same (complex) request. What I would like to do is define an input for a certain endpoint and have some placeholders in there, maybe with defaults if no parameters given.

Like : request 1, dataset x, param x = 0 => result = 'nothing to do'

Like : request 2, dataset x, param x = 100 => result = 'a whole lot to do'

Does apiblueprint supply in this functionality?

Searched for it, and schemas and models seem to come near, but I cannot find any example implementation that does exactly this.

Kind regards, Tim

1 Answers1

2

If I understand your question correctly, what you may want to use is a combination of following features:

Describe your two use cases as two separate transactions in your API Blueprint. Then, you should be able to test them with Dredd. To ensure your API Blueprint is DRY, use the power of Attributes Section and make use of inheritance or mixins. Then, if you still feel like lacking a firmer grip around how Dredd tests the blueprint, you can alter what is being sent using hooks. Dredd Hooks allow you to programatically enhance Dredd's behavior and they can be written in multiple programming languages.

Honza Javorek
  • 6,241
  • 5
  • 42
  • 63
  • Hi Honza, although your answer didn't actually solve my initial problem, it was really, really helpful! Thanks! By now I have one definition of the datastructure and multiple requests, but they still are complete requests, and not deltas to a previous definition. Maybe it's also more readable this way. Thanks! – Tim Meeuwissen Jan 11 '16 at 08:35
  • @Tim Is there anything like this for swagger? I also use dredd and want to be able to call one endpoint with different params: 1) /get_token?auth_code=foo 2) /get_token?refresh_token=bar 3) /get_token?user=foo&pass=bar – Eldar Rakhimberdin Nov 21 '17 at 14:36