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

Question/Feature: Add support for selecting XPath in response template #397

Closed
kashifsoofi opened this issue Jan 8, 2020 · 3 comments · Fixed by #398
Closed

Question/Feature: Add support for selecting XPath in response template #397

kashifsoofi opened this issue Jan 8, 2020 · 3 comments · Fixed by #398
Assignees
Labels

Comments

@kashifsoofi
Copy link
Contributor

Hi,
I am looking to transform soap response. And it would be good if i can use the XPath to select values from request. I believe it can be done using regex but XPath would be a natural fit for this use case.

Question: Is it already supported?

If not happy to do a PR. It would be similar to how json template work.
"{{XPath.Select request.body "/todo-list/todo-item[1]/text()"}}") to return text of 1st element in response.

@StefH
Copy link
Collaborator

StefH commented Jan 8, 2020

This is not yet supported, this could be a valuable addition.
Suggested 2 methods:

  • XPath.SelectSingleNode
  • XPath.SelectNodes

I'll take a look at the code how to implement this.

@StefH StefH added the feature label Jan 8, 2020
@StefH StefH self-assigned this Jan 8, 2020
@kashifsoofi
Copy link
Contributor Author

I am happy to do a PR for this if okay.

@StefH
Copy link
Collaborator

StefH commented Jan 8, 2020

You can make a PR. For reference see the https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Transformers/HandleBarsJsonPath.cs file.

Also make sure to add unit-tests for this new transformer. For reference, see https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsJsonPathTests.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants