I am trying to improve the code to prevent errors. I have a couple of requests that can come in these forms, 1:
{
"idUser": "1234",,
"ids": ["3", "1"]
}
or 2:
{
"idUser": "1234",,
"ids": ["1", "3"]
}
And I have this Json Match:
{
"request": {
"urlPath": "mypath/rest/",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$..ids[0]",
"contains": "1"
}
},
{
"matchesJsonPath": {
"expression": "$..ids[1]",
"contains": "3"
}
}
]
},
"response": {
}
}
How can I make a "contains" in a regex that ignores the order of ids. I have tried :
"matchesJsonPath": "$[?(@..ids =~ /[1-3]+/]"
{
"matchesJsonPath": {
"expression": "$..ids",
"contains": "1"
}
},
{
"matchesJsonPath": {
"expression": "$..ids",
"contains": "3"
}
}
** In case 1 it would not work and in case 2 it would.
Thanks so much!
question from:
https://stackoverflow.com/questions/65919530/wiremock-matchesjsonpath-checking-array-values-ignoring-the-order 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…