mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-22 06:46:53 +02:00
Updated Response Templating (markdown)
+17
-4
@@ -130,10 +130,10 @@ In addition to the standard helpers, also the helpers from [Handlebars.Net.Helpe
|
|||||||
The following extra helpers are present in WireMock.Net:
|
The following extra helpers are present in WireMock.Net:
|
||||||
- [Humanizer](https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/Humanizer)
|
- [Humanizer](https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/Humanizer)
|
||||||
- [JsonPath.SelectToken & JsonPath.SelectTokens](#jsonpath)
|
- [JsonPath.SelectToken & JsonPath.SelectTokens](#jsonpath)
|
||||||
- Linq
|
- [Linq](https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/DynamicLinq)
|
||||||
- [Random](#random)
|
- [Random](#random)
|
||||||
- Regex.Match
|
- Regex.Match
|
||||||
- [XPath.SelectSingleNode & XPath.SelectNodes & XPath.Evaluate](#xpath)
|
- [XPath.SelectSingleNode & XPath.SelectNodes & XPath.Evaluate](#xpath) and [XPath](https://github.com/Handlebars-Net/Handlebars.Net.Helpers/wiki/XPath)
|
||||||
- Xeger
|
- Xeger
|
||||||
|
|
||||||
## JsonPath
|
## JsonPath
|
||||||
@@ -156,6 +156,17 @@ server
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
:warning:
|
||||||
|
When returning a more complex Json Body like this:
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"market": "{{JsonPath.SelectToken request.bodyAsJson '$.pricingContext.market'}}",
|
||||||
|
"languages": "en"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You need to to use single quote (`'`) instead of escaped double quotes (`\"`) because of some parsing error @ Handlebars.Net (see also #1108).
|
||||||
|
|
||||||
Or using the admin mapping file:
|
Or using the admin mapping file:
|
||||||
``` js
|
``` js
|
||||||
{
|
{
|
||||||
@@ -211,6 +222,8 @@ Note that also replacing values in a Json Object and returning a the body as Jso
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Random
|
## Random
|
||||||
It's possible to return random data using the `Random` Handlebars function.
|
It's possible to return random data using the `Random` Handlebars function.
|
||||||
|
|
||||||
@@ -265,6 +278,8 @@ Besides a random text string, it's also possible to generate this random data:
|
|||||||
|
|
||||||
Note: instead of using `\"` in above examples, you can also use `'`.
|
Note: instead of using `\"` in above examples, you can also use `'`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## XPath
|
## XPath
|
||||||
XPath support is also present
|
XPath support is also present
|
||||||
|
|
||||||
@@ -313,5 +328,3 @@ Or using the admin mapping file:
|
|||||||
```
|
```
|
||||||
|
|
||||||
For examples on `XPath.SelectNodes` and `XPath.Evaluate`, see https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsXPathTests.cs
|
For examples on `XPath.SelectNodes` and `XPath.Evaluate`, see https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsXPathTests.cs
|
||||||
|
|
||||||
###
|
|
||||||
Reference in New Issue
Block a user