Hello :wave: I might need your help here :sos: I...
# help
a
Hello πŸ‘‹ I might need your help here πŸ†˜ I have a recorded stub looking like that (no sensitive data, this is a FR railway stations id available as open data):
Copy code
{
  "id": "18b85be5-a24a-3d60-84fa-5ecb160fb7a3",
  "name": "stations",
  "request": {
    "url": "/stations",
    "method": "POST",
    "bodyPatterns": [
      {
        "equalToJson": "[{\"id\":\"8768600\",\"issuer\":\"SNCF\"},{\"id\":\"8775500\",\"issuer\":\"SNCF\"},{\"id\":\"8754700\",\"issuer\":\"SNCF\"},{\"id\":\"8775100\",\"issuer\":\"SNCF\"},{\"id\":\"8775767\",\"issuer\":\"SNCF\"}]",
        "ignoreArrayOrder": true,
        "ignoreExtraElements": false
      }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "stations-18b85be5-a24a-3d60-84fa-5ecb160fb7a3.json",
    "headers": {
      "Keep-Alive": "timeout=60",
      "x-correlation-id": "0dcb6d6f-b31e-4e21-a662-23cbc8ecfe83",
      "Date": "Mon, 17 Mar 2025 16:11:01 GMT",
      "Content-Type": "application/json",
      "Connection": "close"
    }
  },
  "uuid": "18b85be5-a24a-3d60-84fa-5ecb160fb7a3",
  "persistent": true,
  "scenarioName": "scenario-1-stations",
  "requiredScenarioState": "scenario-1-stations-2",
  "insertionIndex": 1
}
Issue: When I try to match the following request, it fails with the error in the screenshot: Request payload:
Copy code
[ {
    "id" : "8775500",
    "issuer" : "SNCF"
  }, {
    "id" : "8768600",
    "issuer" : "SNCF"
  }, {
    "id" : "8754700",
    "issuer" : "SNCF"
  }, {
    "id" : "8775100",
    "issuer" : "SNCF"
  }, {
    "id" : "8775767",
    "issuer" : "SNCF"
  } ]
πŸ‘‰ As you can see, the order is not the same but it should be ignored by
ignoreArrayOrder
πŸ‘‰ If I remove scenarios informations (
scnearioName
and
requiredScenarioState
), it is working well. I have another stubs in the same folder (same payload, same response), which seems linked by their scenario information. I have 2 questions in order to help me here: β€’ Maybe a reusable stubs would solve the issue: Is there a way to tell Wiremock to detect similar stubs to not record two similars and reuse one ? Just found out about
ignoreRepeatRequests
in record spec. Do you think it will solve my case ? β€’ Since scenario information is not really needed for it to work, is there a way to tell wiremock to not save any scenario information ? Thank you very much for your help πŸ™
Here is the other stubs I have in the same folder:
Copy code
{
  "id": "aea6db3b-39a7-3d43-b89c-827b039bc27a",
  "name": "stations",
  "request": {
    "url": "/stations",
    "method": "POST",
    "bodyPatterns": [
      {
        "equalToJson": "[{\"id\":\"8768600\",\"issuer\":\"SNCF\"},{\"id\":\"8775500\",\"issuer\":\"SNCF\"},{\"id\":\"8754700\",\"issuer\":\"SNCF\"},{\"id\":\"8775100\",\"issuer\":\"SNCF\"},{\"id\":\"8775767\",\"issuer\":\"SNCF\"}]",
        "ignoreArrayOrder": true,
        "ignoreExtraElements": false
      }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "stations-aea6db3b-39a7-3d43-b89c-827b039bc27a.json",
    "headers": {
      "Keep-Alive": "timeout=60",
      "x-correlation-id": "0dcb6d6f-b31e-4e21-a662-23cbc8ecfe83",
      "Date": "Mon, 17 Mar 2025 16:11:01 GMT",
      "Content-Type": "application/json",
      "Connection": "close"
    }
  },
  "uuid": "aea6db3b-39a7-3d43-b89c-827b039bc27a",
  "persistent": true,
  "scenarioName": "scenario-1-stations",
  "requiredScenarioState": "Started",
  "newScenarioState": "scenario-1-stations-2",
  "insertionIndex": 2
}
t
Looks like you had the option enabled to create a scenario on repeated requests to the same URL/method when you started recording. Might be worth deleting your stubs and re-recording with that option turned off. It’s called
repeatsAsScenarios
or something like that.
a
Awesome, simple as that ! That
repeatsAsScenarios
is set to false when calling
ignoreRepeatRequests
Thanks, Tom πŸ‘
πŸ‘ 1