- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 233
Closed
Labels
Description
Describe the bug
When the mapping contains multiple handlebars templates in the response body, the response only includes the evaluation of the first handlebars template.
Expected behavior:
WireMock should evaluate all of the handlebars templates in the mapping and include them in the response.
Test to reproduce
Mapping:
[
  {
    "Request": {
      "Path": "/path0/path1",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "{{request.PathSegments.[0]}}{{request.PathSegments.[1]}}"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]Request: GET http://{WIREMOCK_SERVER_HOST}/path0/path1
Expected response:
{
  "field": "path0path1"
}Actual response:
{
  "field": "path0"
}Other related info
This issue only occurs when the handlebars template is the prefix of a field in the response body. Adding any characters before the request path segment resolves the issue.
Mapping:
[
  {
    "Request": {
      "Path": "/path0/path1",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "prefix{{request.PathSegments.[0]}}{{request.PathSegments.[1]}}"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]Request: GET http://{WIREMOCK_SERVER_HOST}/path0/path1
Response:
{
  "field": "prefixpath0path1"
}Related issue: #1212