Hello everybody, I'm trying to use wiremock respo...
# help
b
Hello everybody, I'm trying to use wiremock response templating but having issues with it. In my docker configuration I have following
Copy code
wiremock:
  image: ${PUBLIC_REGISTRY_PROXY:-}wiremock/wiremock:latest
  command: ["--local-response-templating", "--global-response-templating"]
Then my mapping includes
Copy code
"response": {
    "status": 200,
    "bodyFileName": "rooms/apitude/simpsons/availabilities.json",
    "additionalProxyRequestHeaders": {
      "X-Wiremock": "stub"
    },
    "transformers": ["response-template"]
  }
But finally when I log the response in my workflow, the templating does not apply
Copy code
"checkIn": "{{now offset='+1 days' format='yyyy-MM-dd'}}",
Does someone know what's wrong please ?
l
Hi, is there a reason you are specifying both
local-response-templating
and
global-response-templating
. Local is the default in the latest version so you shouldn't need either from what I can tell
b
Hi Lee, not for a particular reason, I was trying some options to make it work I also tried to use
entrypoint: ['/docker-entrypoint.sh', '--global-response-templating', '--verbose']
but this is still not working 😕
l
Are you seeing the response but just with the handlebars not replaced ?
b
yes exactly, so it cant be correctly parsed
l
Strange. I have just tried this with the following setup:
Copy code
version: "3"
services:
  wiremock:
    image: "wiremock/wiremock:nightly"
    ports:
      - "8080:8080"
    container_name: wiremock
    volumes:
      - ./wiremock/__files:/home/wiremock/__files
      - ./wiremock/mappings:/home/wiremock/mappings
      - ./wiremock/extensions:/var/wiremock/extensions
    entrypoint: [ "/docker-entrypoint.sh", "--verbose" ]
Copy code
{
  "request": {
    "method": "GET",
    "url": "/foo"
  },
  "response": {
    "status": 200,
    "bodyFileName": "rooms/apitude/simpsons/availabilities.json",
    "additionalProxyRequestHeaders": {
      "X-Wiremock": "stub"
    },
    "transformers": [
      "response-template"
    ]
  }
}
The
availabilities,json
file contains the following:
Copy code
{
  "checkIn": "{{now offset='+1 days' format='yyyy-MM-dd'}}"
}
When I send a request, I get the following:
Copy code
{
  "checkIn": "2025-03-20"
}
Just out of interest, when you start your container, what version does it show?
b
it shows
version: 3.10.0
l
Ok, that isn’t the latest but I don’t think it should make any difference in this instance.
Is there any chance you could put a small reproducer project together so we can see the issue and try and diagnose? The test I did was done using this example repo https://github.com/leeturner/wiremock-standalone-docker-example
b
Not really as it's built in a really big project 😕 I am using a reverse proxy, could it be an issue ? Its mapped to
<https://wiremock.worldia.loc>
in docker
Copy code
wiremock:
    image: 'wiremock/wiremock:nightly'
    command: '--global-response-templating --verbose'