Is there a way to have a wildcard in the bodyFileName for a wiremock stub mapping?

Viewed 256

My issue is that I want to give my response file names a more meaningful name but to do this I need to be able to match on any text following the id. Here is my current mapping:

{
  "priority": 10,
  "request": {
    "urlPattern": "/api/v1/customer\\?Id=(.*)&IdType=(.*)&AdditionalInformation=(.*)",
    "method": "GET"
  },
  "response": {
    "transformers": [
      "dynamic-mapping-transformer"
    ],
    "status": 200,
    "headers": {
      "Content-Type": "application/json",
      "Correlation-ID": "{{request.headers.Correlation-ID}}"
    },
    "transformerParameters": {
      "bodyFileName": "{{request.query.Id}}",
      "fileDirectory": "getWorkplaceDetails",
      "extension": "json",
      "encodeName": false,
      "caseInsensitive": true
    }
  }
}

And the naming convention for the response files should be something along the lines of "Id_foo_bar" but "foo" and "bar" are not available in the request so there is no way for me to know them before the response is posted. I would like to use a wild card in the bodyFileName value to match on anything after the Id and was wondering if anyone knew a way to do this?

EDIT 1

I forgot to mention that the mapping needs to accept multiple files with different names which is why I am looking to use a wild card instead of a static file name.

0 Answers
Related