Hello! I'm using WireMock very frequently and than...
# help
p
Hello! I'm using WireMock very frequently and thank you very much for that great tool. I've 2 questions with response template Question 1: is it possible to sort an array with integer numbers?
Copy code
{{val (pickRandom (range 1 50) count=5) assign='randomNumbers'}}
sort the values in randomNumbers array? Question 2: is it possible to access an array index via a variable?
Copy code
{{val (array 'foo' 'bar') assign='testArray'}}
{{val 1 assign='index'}}
{{testArray.index}} --> possible?
{{testArray.1}} -> works
I'm using the latest version of WireMock (3.12.1) thank you very much for your help and wish you a great day!
t
Hi Philipp, thanks for the kind feedback! There isn’t a
sort
help available at the moment unfortunately. It definitely seems like it’d be a great addition to WireMock if you feel like opening a PR? For your second question, here’s how you do it:
Copy code
{{val (array 'foo' 'bar') assign='testArray'}}
{{val 1 assign='index'}}
{{lookup testArray index}}
p
Thank you very much for the quick reply @Tom! works perfect 👍 will create the PR (enhancement?) soon 🙂
👍 2
Enhancement issue (#3013) created
l
Hey @Philipp Gorkiewicz, I'm looking for ways to contribute to the repository and I saw the enhancement ticket in github and then found this thread. Are you still planning to open a PR for this feature? Otherwise, I was thinking I could give it a try. Thanks!
p
Hi @Luis Copetti, I created it as enhancement as not really a PR (Bug), in my opinion! (#3013)