Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response Body Does Not Include Text After Path Segment #1212

Closed
adambricelis opened this issue Nov 19, 2024 · 1 comment
Closed

Response Body Does Not Include Text After Path Segment #1212

adambricelis opened this issue Nov 19, 2024 · 1 comment
Assignees
Labels

Comments

@adambricelis
Copy link

Describe the bug

When a field in the response body is prefixed with a path segment from the request, the text after that path segment is not included in the response body.

Expected behavior:

WireMock should evaluate all of the text in the mapping and include all of it in the response.

Test to reproduce

Mapping:

[
  {
    "Request": {
      "Path": "/path",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "{{request.PathSegments.[0]}}text_being_removed_incorrectly"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]

Request: GET http://{WIREMOCK_SERVER_HOST}/path
Expected response:

{
  "field": "pathtext_being_removed_incorrectly"
}

Actual response:

{
  "field": "path"
}

Other related info

This issue only occurs when the request path segment is the prefix of a field in the response body. Adding any characters before the request path segment resolves the issue.

Mapping:

[
  {
    "Request": {
      "Path": "/path",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "prefix{{request.PathSegments.[0]}}text_being_removed_incorrectly"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]

Request: GET http://{WIREMOCK_SERVER_HOST}/path
Response:

{
  "field": "prefixpathtext_being_removed_incorrectly"
}
@StefH StefH self-assigned this Nov 21, 2024
@StefH
Copy link
Collaborator

StefH commented Nov 21, 2024

#1213

@StefH StefH closed this as completed Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants