wiremock icon indicating copy to clipboard operation
wiremock copied to clipboard

Unwrap ListOrSingle values in helpers

Open tomakehurst opened this issue 5 years ago • 3 comments

Currently helpers e.g. eq and jsonPath don't work properly with ListOrSingle values unless you explicitly use the indexed form.

This is pretty confusing so helpers should check for this condition and unwrap singular values from ListOrSingle so that the index becomes unnecessary.

tomakehurst avatar Feb 24 '20 10:02 tomakehurst

@tomakehurst Is this issue still active?

berlincho avatar Nov 30 '21 03:11 berlincho

I notice there is a previous commit https://github.com/wiremock/wiremock/commit/618d82517f3180340b7b54ce051dbfd3004addd3 in JsonPath. Does anything require to improve so far?

berlincho avatar Nov 30 '21 04:11 berlincho

I haven't yet found a way to do this that doesn't cause regressions. I think it's safe to assume it's not going to happen for quite a while, if at all.

You always have the option of using the indexed form of the attributes, or if you've got multiple values you can use the new contains helper e.g. {{#contains request.query.myParam 'value'}}

tomakehurst avatar Nov 30 '21 08:11 tomakehurst