Skip to content

Commit

Permalink
Update custom-matching.md
Browse files Browse the repository at this point in the history
Reducing vertical space in documentation for code examples using code tabs.
  • Loading branch information
Smartmind12 authored Oct 1, 2023
1 parent b7a2c02 commit 08c709c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions _docs/extensibility/custom-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ public class BodyLengthMatcher extends RequestMatcherExtension {

Then define a stub with it:

{% codetabs %}

{% codetab Java %}

```java
stubFor(requestMatching("body-too-long", Parameters.one("maxLength", 2048))
.willReturn(aResponse().withStatus(422)));
```

or via JSON:
{% endcodetab %}

{% codetab JSON %}

```json
{
Expand All @@ -93,6 +99,10 @@ or via JSON:
}
```

{% endcodetab %}

{% endcodetabs %}

### Combining standard and custom request matchers

An inline custom matcher can be used in combination with standard matchers in the following way:
Expand All @@ -108,15 +118,19 @@ WireMock server. An exception will be thrown if attempting to use an inline cust

Custom matchers defined as extensions can also be combined with standard matchers.

Java:
{% codetabs %}

{% codetab Java %}

```java
stubFor(get(urlPathMatching("/the/.*/one"))
.andMatching("path-contains-param", Parameters.one("path", "correct"))
.willReturn(ok()));
```

JSON:
{% endcodetab %}

{% codetab JSON %}

```json
{
Expand All @@ -134,4 +148,8 @@ JSON:
"status": 200
}
}
```
```

{% endcodetab %}

{% endcodetabs %}

0 comments on commit 08c709c

Please sign in to comment.