mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 01:08:49 +02:00
Updated Stubbing (markdown)
33
Stubbing.md
33
Stubbing.md
@@ -44,12 +44,12 @@ server
|
|||||||
## Request Matching
|
## Request Matching
|
||||||
WireMock supports matching of requests to stubs and verification queries using the following attributes:
|
WireMock supports matching of requests to stubs and verification queries using the following attributes:
|
||||||
|
|
||||||
* URL
|
* Path/URL
|
||||||
* HTTP Method
|
* HTTP Method
|
||||||
* Query parameters
|
* Query parameters
|
||||||
* Headers
|
* Headers
|
||||||
* Cookies
|
* Cookies
|
||||||
* Request body
|
* Request Body
|
||||||
|
|
||||||
|
|
||||||
### JSON Path
|
### JSON Path
|
||||||
@@ -99,6 +99,35 @@ Will match xml below:
|
|||||||
</todo-list>
|
</todo-list>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Regular Expression Matching
|
||||||
|
The RegexMatcher can be used to match using a regular expression.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// todo example
|
||||||
|
```
|
||||||
|
|
||||||
|
### Similarity Metric Matching
|
||||||
|
SimMetrics.Net is used is a Similarity Metric Library, e.g. from edit distance's (Levenshtein, Gotoh, Jaro etc) to other metrics, (e.g Soundex, Chapman).
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// todo example
|
||||||
|
```
|
||||||
|
|
||||||
|
### WildcardMatching
|
||||||
|
WildcardMatching is mostly used for Path and Url matching. This matcher allows a ? for a single character and * for any characters.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var server = FluentMockServer.Start();
|
||||||
|
server
|
||||||
|
.Given(Request.Create().WithPath("/some*").UsingGet())
|
||||||
|
.RespondWith(Response.Create().WithBody("Hello"));
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
// matching
|
||||||
|
Url like /somebody and /someting
|
||||||
|
```
|
||||||
|
|
||||||
## Response Templating
|
## Response Templating
|
||||||
Response headers and bodies can optionally be rendered using [Handlebars.Net](https://github.com/rexm/Handlebars.Net) templates.
|
Response headers and bodies can optionally be rendered using [Handlebars.Net](https://github.com/rexm/Handlebars.Net) templates.
|
||||||
This enables attributes of the request to be used in generating the response e.g. to pass the value of a request ID header as a response header or render an identifier from part of the URL in the response body. To use this functionality, add `.WithTransformer()` to the response builder.
|
This enables attributes of the request to be used in generating the response e.g. to pass the value of a request ID header as a response header or render an identifier from part of the URL in the response body. To use this functionality, add `.WithTransformer()` to the response builder.
|
||||||
|
|||||||
Reference in New Issue
Block a user