https://linen.dev logo
#general
Title
# general
s

sidi amine bouhamidi

03/26/2023, 9:02 PM
Hi there! I am using the dockerized version of wiremock, everything working well except the response templating
{{now}}
. I looked everywhere to find out how to activate it. Could you please help me? • How I start the container :
Copy code
docker run -itd --rm -p 9000:8080 --name wiremock -v $PWD/mocks:/home/wiremock wiremock/wiremock
• My Stub in
$PWD/mocks/stub-get-session-200.json
Copy code
{
  "request": {
    "method": "GET",
    "url": "/api/v1/session"
  },
  "response": {
    "status": 200,
    "jsonBody": {
      "expiresAt": "{{now offset='900 seconds'}}"
    },
    "transformers": [
      "response-template"
    ],
    "headers": {
      "Content-Type": "application/json"
    }
  }
}
• The response when I call the API
<http://localhost:9000/api/v1/session>
Copy code
{
  "expiresAt": "{{now offset='900 seconds'}}"
}
t

Tom

03/27/2023, 10:33 AM
Hi @sidi amine bouhamidi you need to add the
--local-response-templating
CLI parameter when starting up WireMock.
s

sidi amine bouhamidi

03/28/2023, 3:13 PM
thank you @Tom for your answer. I started my container with the extra parameter but still have the same problem described above.
Copy code
docker run -itd --rm -p 9000:8080 --name wiremock -v $PWD/mocks:/home/wiremock wiremock/wiremock --local-response-templating
oh! now it's working. I added
"transformers": ["response-template"]
and everything is working well now
thank you @Tom
👍 1