Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tommysitu committed Jan 24, 2023
1 parent 477b0d3 commit 147d43f
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions docs/pages/reference/hoverfly/request_matchers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
Request matchers
================

A Request Matcher is used to define the desired value for a specific request field when matching against incoming requests.
A Request Matcher is used to define the desired value for a specific request field when matching against incoming requests.
Given a **matcher value** and **string to match**, each matcher will transform and compare the values in a different way.


Exact matcher
-------------
Evaluates the equality of the matcher value and the string to match. There are no transformations.
This is the default Request Matcher type which is set by Hoverfly when requests and responses are captured.
Evaluates the equality of the matcher value and the string to match. There are no transformations.
This is the default Request Matcher type which is set by Hoverfly when requests and responses are captured.

Example
"""""""

.. code:: json
"matcher": "exact"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -56,12 +56,12 @@ Example
"""""""

.. code:: json
"matcher": "glob"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -99,19 +99,19 @@ Example
Regex matcher
-------------
Parses the matcher value as a regular expression which is then executed against the string to match. This will pass only if the regular expression successfully
Parses the matcher value as a regular expression which is then executed against the string to match. This will pass only if the regular expression successfully
returns a result.

Example
"""""""

.. code:: json
"matcher": "regex"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -155,12 +155,12 @@ Example
"""""""

.. code:: json
"matcher": "xml"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -202,19 +202,19 @@ Example
XPath matcher
-------------
Parses the matcher value as an XPath expression, transforms the string to match into an XML object and then executes the expression against it. This will pass only if the expression successfully
Parses the matcher value as an XPath expression, transforms the string to match into an XML object and then executes the expression against it. This will pass only if the expression successfully
returns a result.

Example
"""""""

.. code:: json
"matcher": "xpath"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -279,12 +279,12 @@ Example
"""""""

.. code:: json
"matcher": "json"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand All @@ -298,7 +298,7 @@ Example
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
},{
"name": "Object 2",
Expand All @@ -309,7 +309,7 @@ Example
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
},{
"name": "Object 2",
Expand All @@ -323,14 +323,14 @@ Example
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
}]
}</td>
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
},{
"name": "Object 2",
Expand Down Expand Up @@ -437,20 +437,20 @@ Example
JSONPath matcher
----------------
Parses the matcher value as a JSONPath expression, transforms the string to match into a JSON object and then executes
Parses the matcher value as a JSONPath expression, transforms the string to match into a JSON object and then executes
the expression against it. This will pass only if the expression successfully returns a result.


Example
"""""""

.. code:: json
"matcher": "jsonpath"
"value": "?"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand All @@ -464,7 +464,7 @@ Example
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
}]
}</td>
Expand All @@ -473,7 +473,7 @@ Example
<tr/>
<tr class="row-odd">
<td class="example">{
"name": "Object 1",
"name": "Object 1",
"set": true
}</td>
<td>$.objects</td>
Expand All @@ -483,27 +483,27 @@ Example
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
}]
}</td>
<td>$.objects[1].name</td>
<td class="example-icon"><span class="fa fa-times fa-failure"></span></td>

<tr/>
<tr class="row-odd">
<td class="example">{
"objects": [
{
"name": "Object 1",
"name": "Object 1",
"set": true
}, {
"name": "Object 2",
"name": "Object 2",
"set": false
}]
}</td>
<td>$.objects[1].name</td>
<td class="example-icon"><span class="fa fa-check fa-success"></span></td>
<td class="example-icon"><span class="fa fa-check fa-success"></span></td>
<tr/>
</tbody>
</table>
Expand All @@ -518,12 +518,12 @@ Example
"""""""

.. code:: json
"matcher": "containsexactly"
"value": "[?]"
.. raw:: html

<table border="1" class="docutils matcher-examples">
<thead>
<tr class="row-odd">
Expand Down Expand Up @@ -552,27 +552,27 @@ Generic Array matcher

Matches the matcher group with value passed in request array based on the configuration passed.

- ignoreorder - ignore order in which values that are passed.
- ignoreunknowns - ignore unknowns in the values that are passed.
- ignoreoccurrences - ignore number of occurrences of elements that are passed with respect to matcher value.
- ignoreOrder - ignore order in which values that are passed.
- ignoreUnknown - ignore unknowns in the values that are passed.
- ignoreOccurrences - ignore number of occurrences of elements that are passed with respect to matcher value.

Example
"""""""

.. code:: json
"matcher": "array"
"value": "[?]"
"configuration": "{}"
Example:
{
"matcher": "array",
"config": {
"ignoreunknown": <true/false>,
"ignoreorder": <true/false>,
"ignoreoccurrences": <true/false>
"ignoreUnknown": <true/false>,
"ignoreOrder": <true/false>,
"ignoreOccurrences": <true/false>
},
"value": [
"access:vod",
Expand All @@ -583,7 +583,7 @@ Example
JWT Matcher
-----------
This matcher is primarily used for matching JWT tokens. This matcher converts base64 encoded JWT to JSON document ({"header": {}, "payload": ""}) and does partial match with the matcher value.
This matcher is primarily used for matching JWT tokens. This matcher converts base64 encoded JWT to JSON document ({"header": {}, "payload": ""}) and does partial match with the matcher value.
Matcher value contains only keys that they want to match in JWT.

Expand All @@ -599,17 +599,17 @@ Matcher Chaining
----------------

- Matcher chaining helps to chain multiple matchers. MatchedValue of parent matcher is feed into child matcher and further matching is done.

- It typically removes the stress of composing and testing complex expressions and make matchers more readable.

- It can be combine any of matchers.

For an example, with matcher chaining, one can use JSONPath to get a JSON node, and use other matcher to compare its value as mentioned below.
For an example, with matcher chaining, one can use JSONPath to get a JSON node, and use other matcher to compare its value as mentioned below.

Example
"""""""
.. code:: json
"matcher":<any matcher>,
"value":?,
"doMatch": {
Expand Down

0 comments on commit 147d43f

Please sign in to comment.