<p>The following code examples show how to match against different elements of a request using different matchers.  For more examples see the <a target="_blank" href="https://github.com/mock-server/mockserver-monorepo/tree/master/examples" rel="noopener noreferrer">code examples folder</a> in the git repository.</p>
<p>For brevity static imports have not been included in the Java code examples so please add the following static imports if copying this code</p>
<pre class="prettyprint lang-java code"><code class="code">import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;</code></pre>
<br/>
<button id="button_match_request_by_priority" class="accordion">match requests using priority</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path"),
        Times.once(),
        TimeToLive.exactly(TimeUnit.SECONDS, 60L),
        10
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path"
    },
    "httpResponse": {
        "body": "some_response_body"
    },
    "times": {
        "remainingTimes": 1,
        "unlimited": false
    },
    "timeToLive": {
        "timeUnit": "SECONDS",
        "timeToLive": 60,
        "unlimited": false
    },
    "priority" : 10
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  },
  "times" : {
    "remainingTimes" : 1,
    "unlimited" : false
  },
  "timeToLive" : {
    "timeUnit" : "SECONDS",
    "timeToLive" : 60,
    "unlimited" : false
  },
  "priority" : 10
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_negative_priority" class="accordion">match requests using default expectation</button>
<div class="panel">
    <p>A negative priority can be used to specify a default expectation or response.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request(),
        Times.once(),
        TimeToLive.exactly(TimeUnit.SECONDS, 60L),
        -10
    )
    .respond(
        response()
            .withBody("some_default_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {},
    "httpResponse": {
        "body": "some_default_response_body"
    },
    "times": {
        "remainingTimes": 1,
        "unlimited": false
    },
    "timeToLive": {
        "timeUnit": "SECONDS",
        "timeToLive": 60,
        "unlimited": false
    },
    "priority" : -10
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {},
  "httpResponse" : {
    "body" : "some_default_response_body"
  },
  "times" : {
    "remainingTimes" : 1,
    "unlimited" : false
  },
  "timeToLive" : {
    "timeUnit" : "SECONDS",
    "timeToLive" : 60,
    "unlimited" : false
  },
  "priority" : -10
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path" class="accordion">match request by path</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path"
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path_exactly_twice" class="accordion">match request by path exactly twice</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path"),
        Times.exactly(2)
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path"
    },
    "httpResponse": {
        "body": "some_response_body"
    },
    "times": {
        "remainingTimes": 2
    },
    "timeToLive": {
        "unlimited": true
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  },
  "times" : {
    "remainingTimes" : 2,
    "unlimited" : false
  },
  "timeToLive" : {
    "unlimited" : true
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path_exactly_once_in_the_next_60_seconds" class="accordion">match request by path exactly once in the next 60 seconds</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path"),
        Times.once(),
        TimeToLive.exactly(TimeUnit.SECONDS, 60L)
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path"
    },
    "httpResponse": {
        "body": "some_response_body"
    },
    "times": {
        "remainingTimes": 1,
        "unlimited": false
    },
    "timeToLive": {
        "timeUnit": "SECONDS",
        "timeToLive": 60,
        "unlimited": false
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  },
  "times" : {
    "remainingTimes" : 1,
    "unlimited" : false
  },
  "timeToLive" : {
    "timeUnit" : "SECONDS",
    "timeToLive" : 60,
    "unlimited" : false
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_regex_path" class="accordion">match request by regex path</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches any requests those path starts with "/some"
            .withPath("/some.*")
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests those path starts with "/some"
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some.*"
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some.*"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_path" class="accordion">match request by not matching path</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches any requests those path does NOT start with "/some"
            .withPath(not("/some.*"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests those path does NOT start with "/some"
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "!/some.*"
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "!/some.*"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path_and_path_parameters" class="accordion">match request by path parameter and query parameter</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withPathParameters(
                param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
            )
            .withQueryStringParameters(
                param("type", "[A-Z0-9\\-]+")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
    "path": "/some/path/{cartId}",
        "pathParameters": {
            "cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
        },
        "queryStringParameters": {
            "type": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
    "path": "/some/path/{cartId}",
        "pathParameters": {
            "cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
        },
        "queryStringParameters": {
            "type": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path_parameter_regex_value" class="accordion">match request by path parameter regex value</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path/{cartId}")
            .withPathParameters(
                param("cartId", "[A-Z0-9\\-]+")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path/{cartId}",
        "pathParameters": {
            "cartId": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path/{cartId}",
        "pathParameters": {
            "cartId": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_path_parameter_json_schema_value" class="accordion">match request by path parameter with json schema value</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path/{cartId}/{maxItemCount}")
            .withPathParameters(
                schemaParam("cartId", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
                param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path/{cartId}/{maxItemCount}",
        "pathParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "pattern": "^[A-Z0-9-]+$"
                }
            }],
            "maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path/{cartId}/{maxItemCount}",
        "pathParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "pattern": "^[A-Z0-9-]+$"
                }
            }],
            "maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_compound_path_segment" class="accordion">match request by compound path segment (multiple values in one segment)</button>
<div class="panel">
    <p>To match a path segment containing multiple values separated by delimiters (e.g. <code>/2024-01-15/report</code>), use a single path parameter with a regex value to match the entire compound segment.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches paths like /2024-01-15/report or /val1-val2-val3/report
            .withPath("/{compound}/report")
            .withPathParameters(
                param("compound", "[^/]+-[^/]+-[^/]+")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
// matches paths like /2024-01-15/report or /val1-val2-val3/report
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/{compound}/report",
        "pathParameters": {
            "compound": ["[^/]+-[^/]+-[^/]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/{compound}/report",
        "pathParameters": {
            "compound": ["[^/]+-[^/]+-[^/]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_method_regex" class="accordion">match request by method regex</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches any requests that does NOT have a "GET" method
            .withMethod(not("P.*{2,3}"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "P.*{2,3}"
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "P.*{2,3}"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_method" class="accordion">match request by not matching method</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches any requests that does NOT have a "GET" method
            .withMethod(not("GET"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
// matches any requests that does NOT have a "GET" method
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "!GET"
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "!GET"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_query_parameter_name_regex" class="accordion">match request by query parameter with name regex</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(
                param("[A-z]{0,10}", "055CA455-1DF7-45BB-8535-4F83E7266092")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "[A-z]{0,10}": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "[A-z]{0,10}": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_query_parameter_value_regex" class="accordion">match request by query parameter with regex value</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(
                param("cartId", "[A-Z0-9\\-]+")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "cartId": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "cartId": ["[A-Z0-9\\-]+"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_query_parameter_value_json_schema" class="accordion">match request by query parameter with json schema value</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <p>This example shows the two ways a JSON Schema can be specified to match a query parameter value, either using the <strong>schemaParam</strong> static builder for parameters or the <strong>schemaString</strong> for static builder
            strings.</p>
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(
                schemaParam("cartId", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
                param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "pattern": "^[A-Z0-9-]+$"
                }
            }],
            "maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "pattern": "^[A-Z0-9-]+$"
                }
            }],
            "maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_optional_query_parameter" class="accordion">match request by optional query parameter</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <p>This example shows the two ways to specify an optional query parameter value, either using the <strong>optionalParam</strong> static builder for parameters or the <strong>optionalString</strong> for static builder strings.</p>
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(
                optionalParam("cartId", "[A-Z0-9\\-]+"),
                param(optionalString("maxItemCount"), schemaString("{ \"type\": \"integer\" }")),
                schemaParam(optionalString("userId"), "{ \"type\": \"string\", \"format\": \"uuid\" }")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "?cartId": ["[A-Z0-9\\-]+"],
            "?maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }],
            "?userId": [{
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "queryStringParameters": {
            "?cartId": ["[A-Z0-9\\-]+"],
            "?maxItemCount": [{
                "schema": {
                    "type": "integer"
                }
            }],
            "?userId": [{
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_query_parameter_by_sub_set" class="accordion">match request by query parameter as sub set</button>
<div class="panel">
    <p>Matching by keys to multiple-values by <strong>SUB_SET</strong> is the default mode this ensures at least one value with the same key matches, but <strong>MATCHING_KEY</strong> is also supported which ensures all values with the same
        key match.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(new Parameters(
                schemaParam("multiValuedParameter", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
                param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
            ).withKeyMatchStyle(KeyMatchStyle.SUB_SET))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <p>Matching by <strong>SUB_SET</strong> is the default mode so nothing needs to be specified for this key match style.</p>
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest" : {
        "path" : "/some/path",
        "queryStringParameters" : {
            "multiValuedParameter" : [ {
                "schema" : {
                    "type" : "string",
                    "pattern" : "^[A-Z0-9-]+$"
                }
            } ],
            "maxItemCount" : [ {
                "schema" : {
                    "type" : "integer"
                }
            } ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <p>Matching by <strong>SUB_SET</strong> is the default mode so nothing needs to be specified for this key match style.</p>
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest" : {
        "path" : "/some/path",
        "queryStringParameters" : {
            "multiValuedParameter" : [ {
                "schema" : {
                    "type" : "string",
                    "pattern" : "^[A-Z0-9-]+$"
                }
            } ],
            "maxItemCount" : [ {
                "schema" : {
                    "type" : "integer"
                }
            } ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_query_parameter_by_matching_key" class="accordion">match request by query parameter as matching key</button>
<div class="panel">
    <p>Matching by keys to multiple-values by <strong>SUB_SET</strong> is the default mode this ensures at least one value with the same key matches, but <strong>MATCHING_KEY</strong> is also supported which ensures all values with the same
        key match.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withQueryStringParameters(new Parameters(
                schemaParam("multiValuedParameter", "{\"type\": \"string\", \"pattern\": \"^[A-Z0-9\\-]+$\"}"),
                param(string("maxItemCount"), schemaString("{ \"type\": \"integer\" }"))
            ).withKeyMatchStyle(KeyMatchStyle.MATCHING_KEY))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest" : {
        "path" : "/some/path",
        "queryStringParameters" : {
            "keyMatchStyle" : "MATCHING_KEY",
            "multiValuedParameter" : [ {
                "schema" : {
                    "type" : "string",
                    "pattern" : "^[A-Z0-9-]+$"
                }
            } ],
            "maxItemCount" : [ {
                "schema" : {
                    "type" : "integer"
                }
            } ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest" : {
        "path" : "/some/path",
        "queryStringParameters" : {
            "keyMatchStyle" : "MATCHING_KEY",
            "multiValuedParameter" : [ {
                "schema" : {
                    "type" : "string",
                    "pattern" : "^[A-Z0-9-]+$"
                }
            } ],
            "maxItemCount" : [ {
                "schema" : {
                    "type" : "integer"
                }
            } ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_headers" class="accordion">match request by headers</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withMethod("GET")
            .withPath("/some/path")
            .withHeaders(
                header("Accept", "application/json"),
                header("Accept-Encoding", "gzip, deflate, br")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "GET",
        "path": "/some/path",
        "headers": {
            "Accept": ["application/json"],
            "Accept-Encoding": ["gzip, deflate, br"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "GET",
    "path" : "/some/path",
    "headers" : {
      "Accept" : [ "application/json" ],
      "Accept-Encoding" : [ "gzip, deflate, br" ]
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_header_name_regex" class="accordion">match request by header name regex</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeader(
                header("Accept.*")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            // matches requests that have any header starting with the name Accept
            "Accept.*": [ "" ]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">// matches requests that have any header starting with the name Accept
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "Accept.*": [ "" ]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_header_value_regex" class="accordion">match request by header name and regex value</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeader(
                header("Accept.*", ".*gzip.*")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            // matches requests that have a header with a name starting with Accept and a value containing gzip
            "Accept.*": [".*gzip.*"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">// matches requests that have a header with a name starting with Accept and a value containing gzip
curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "Accept.*": [".*gzip.*"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_header_value" class="accordion">match request by not matching header value</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeaders(
                // matches requests that have an Accept header without the value "application/json"
                header(string("Accept"), not("application/json")),
                // matches requests that have an Accept-Encoding without the substring "gzip"
                header(string("Accept-Encoding"), not(".*gzip.*"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            // matches requests that have an Accept header without the value "application/json"
            "Accept": ["!application/json"],
            // matches requests that have an Accept-Encoding without the substring "gzip"
            "Accept-Encoding": ["!.*gzip.*"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path",
    "headers" : {
      "Accept" : [ "!application/json" ],
      "Accept-Encoding" : [ "!.*gzip.*" ]
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_headers" class="accordion">match request by not matching headers</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeaders(
                // matches requests that do not have either an Accept or an Accept-Encoding header
                header(not("Accept")),
                header(not("Accept-Encoding"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            // matches requests that do not have either an Accept or an Accept-Encoding header
            "!Accept": [".*"],
            "!Accept-Encoding": [".*"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "path" : "/some/path",
    "headers" : {
      "!Accept" : [ ".*" ],
      "!Accept-Encoding" : [ ".*" ]
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_header_value_json_schema" class="accordion">match request by header with json schema value</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeader(
                schemaHeader("Accept.*", "{\"type\": \"string\", \"pattern\": \"^.*gzip.*$\"}")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "Accept.*": [{
                "schema": {
                    "type": "string",
                    "pattern": "^.*gzip.*$"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "Accept.*": [{
                "schema": {
                    "type": "string",
                    "pattern": "^.*gzip.*$"
                }
            }]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_optional_header" class="accordion">match request by either one header or another header using optional header</button>
<div class="panel">
    <p>This example shows how to match by either one value (in this case a header) or another value or both.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeaders(
                header("headerOne|headerTwo", ".*"),
                optionalHeader("headerOne", "headerOneValue"),
                optionalHeader("headerTwo", "headerTwoValue")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "headerOne|headerTwo": [".*"],
            "?headerOne": ["headerOneValue"],
            "?headerTwo": ["headerTwoValue"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/some/path",
        "headers": {
            "headerOne|headerTwo": [".*"],
            "?headerOne": ["headerOneValue"],
            "?headerTwo": ["headerTwoValue"]
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_header_by_matching_key" class="accordion">match request by header as matching key</button>
<div class="panel">
    <p>Matching by keys to multiple-values by <strong>SUB_SET</strong> is the default mode this ensures at least one value with the same key matches, but <strong>MATCHING_KEY</strong> is also supported which ensures all values with the same
        key match.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/some/path")
            .withHeaders(new Headers(
                header("multiValuedHeader", "value.*"),
                header("headerTwo", "headerTwoValue")
            ).withKeyMatchStyle(KeyMatchStyle.MATCHING_KEY))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest" : {
        "path" : "/some/path",
        "headers" : {
            "keyMatchStyle" : "MATCHING_KEY",
            "multiValuedHeader" : [ "value.*" ],
            "headerTwo" : [ "headerTwoValue" ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest" : {
        "path" : "/some/path",
        "headers" : {
            "keyMatchStyle" : "MATCHING_KEY",
            "multiValuedHeader" : [ "value.*" ],
            "headerTwo" : [ "headerTwoValue" ]
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_cookies_and_query_parameters" class="accordion">match request by cookie and query parameter</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withMethod("GET")
            .withPath("/view/cart")
            .withCookies(
                cookie("session", "4930456C-C718-476F-971F-CB8E047AB349")
            )
            .withQueryStringParameters(
                param("cartId", "055CA455-1DF7-45BB-8535-4F83E7266092")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "GET",
        "path": "/view/cart",
        "queryStringParameters": {
            "cartId": ["055CA455-1DF7-45BB-8535-4F83E7266092"]
        },
        "cookies": {
            "session": "4930456C-C718-476F-971F-CB8E047AB349"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "GET",
    "path" : "/view/cart",
    "queryStringParameters" : {
      "cartId" : [ "055CA455-1DF7-45BB-8535-4F83E7266092" ]
    },
    "cookies" : {
      "session" : "4930456C-C718-476F-971F-CB8E047AB349"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_cookies_value_json_schema" class="accordion">match request by cookie and query parameter with json schema values</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withMethod("GET")
            .withPath("/view/cart")
            .withQueryStringParameters(
                schemaParam("cartId", "{ \"type\": \"string\", \"format\": \"uuid\" }")
            )
            .withCookies(
                schemaCookie("session", "{ \"type\": \"string\", \"format\": \"uuid\" }")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "GET",
        "path": "/view/cart",
        "queryStringParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }]
        },
        "cookies": {
            "session": {
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "GET",
    "path" : "/view/cart",
    "queryStringParameters" : {
      "cartId" : [ "055CA455-1DF7-45BB-8535-4F83E7266092" ]
    },
    "cookies" : {
      "session" : "4930456C-C718-476F-971F-CB8E047AB349"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_optional_cookies" class="accordion">match request by optional cookie</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withPath("/view/cart")
            .withCookies(
                optionalCookie("session", schemaString("{ \"type\": \"string\", \"format\": \"uuid\" }"))
            )
            .withQueryStringParameters(
                schemaParam("cartId", "{ \"type\": \"string\", \"format\": \"uuid\" }")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "path": "/view/cart",
        "queryStringParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }]
        },
        "cookies": {
            "?session": {
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "path": "/view/cart",
        "queryStringParameters": {
            "cartId": [{
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }]
        },
        "cookies": {
            "?session": {
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_sub_string" class="accordion">match request by body sub-string</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(subString("some_string"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "type": "STRING",
            "string": "some_string",
            "subString": true
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "type": "STRING",
      "string": "some_string",
      "subString": true
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_in_utf16" class="accordion">match request by body in utf16</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(exact("我说中国话", Charsets.UTF_16))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "type": "STRING",
            "string": "我说中国话",
            "contentType": "text/plain; charset=utf-16"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "type" : "STRING",
      "string" : "我说中国话",
      "contentType" : "text/plain; charset=utf-16"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_regex_body" class="accordion">match request by regex body</button>
<div class="panel">
    <p>For details of the full regex syntax supported please see <a target="_blank" href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html" rel="noopener noreferrer">the JDK documentation</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(regex("starts_with_.*"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "type": "REGEX",
            "regex": "starts_with_.*"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest": {
    "body": {
      "type": "REGEX",
      "regex": "starts_with_.*"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_form_submission_body" class="accordion">match request by form submission body</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withMethod("POST")
            .withHeaders(
                header("Content-Type", "application/x-www-form-urlencoded")
            )
            .withBody(
                params(
                    param("email", "joe.blogs@gmail.com"),
                    param("password", "secure_Password123")
                )
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "POST",
        "headers": {
            "Content-Type": ["application/x-www-form-urlencoded"]
        },
        "body": {
            "type": "PARAMETERS",
            "parameters": {
                "email": ["joe.blogs@gmail.com"],
                "password": ["secure_Password123"]
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "method" : "POST",
    "headers" : {
      "Content-Type" : [ "application/x-www-form-urlencoded" ]
    },
    "body" : {
      "type" : "PARAMETERS",
      "parameters" : {
        "email" : [ "joe.blogs@gmail.com" ],
        "password" : [ "secure_Password123" ]
      }
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_xpath" class="accordion">match request by body with xpath</button>
<div class="panel">
    <p>Matches if at least one value is returned by the JsonPath expression</p>
    <p>For a quick summary the XPath syntax please see <a target="_blank" href="https://www.w3schools.com/xml/xpath_syntax.asp" rel="noopener noreferrer">w3schools</a>, for details of the full XPath syntax please see <a target="_blank" href="https://www.w3.org/TR/1999/REC-xpath-19991116/#path-abbrev" rel="noopener noreferrer">www.w3.org</a></p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            // matches any request with an XML body that contains
            // one or more elements that match the XPath expression
            .withBody(
                xpath("/bookstore/book[price>30]/price")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );

// matches a request with the following body:
/*
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;bookstore&gt;
  &lt;book category=&quot;COOKING&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Everyday Italian&lt;/title&gt;
    &lt;author&gt;Giada De Laurentiis&lt;/author&gt;
    &lt;year&gt;2005&lt;/year&gt;
    &lt;price&gt;30.00&lt;/price&gt;
  &lt;/book&gt;
  &lt;book category=&quot;CHILDREN&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Harry Potter&lt;/title&gt;
    &lt;author&gt;J K. Rowling&lt;/author&gt;
    &lt;year&gt;2005&lt;/year&gt;
    &lt;price&gt;29.99&lt;/price&gt;
  &lt;/book&gt;
  &lt;book category=&quot;WEB&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Learning XML&lt;/title&gt;
    &lt;author&gt;Erik T. Ray&lt;/author&gt;
    &lt;year&gt;2003&lt;/year&gt;
    &lt;price&gt;31.95&lt;/price&gt;
  &lt;/book&gt;
&lt;/bookstore&gt;
 */</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            // matches any request with an XML body that contains
            // one or more elements that match the XPath expression
            "type": "XPATH",
            "xpath": "/bookstore/book[price>30]/price"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
});

// matches a request with the following body:
/*
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;bookstore&gt;
  &lt;book category=&quot;COOKING&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Everyday Italian&lt;/title&gt;
    &lt;author&gt;Giada De Laurentiis&lt;/author&gt;
    &lt;year&gt;2005&lt;/year&gt;
    &lt;price&gt;30.00&lt;/price&gt;
  &lt;/book&gt;
  &lt;book category=&quot;CHILDREN&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Harry Potter&lt;/title&gt;
    &lt;author&gt;J K. Rowling&lt;/author&gt;
    &lt;year&gt;2005&lt;/year&gt;
    &lt;price&gt;29.99&lt;/price&gt;
  &lt;/book&gt;
  &lt;book category=&quot;WEB&quot;&gt;
    &lt;title lang=&quot;en&quot;&gt;Learning XML&lt;/title&gt;
    &lt;author&gt;Erik T. Ray&lt;/author&gt;
    &lt;year&gt;2003&lt;/year&gt;
    &lt;price&gt;31.95&lt;/price&gt;
  &lt;/book&gt;
&lt;/bookstore&gt;
 */</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "type" : "XPATH",
      "xpath" : "/bookstore/book[price>30]/price"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_body_with_xpath" class="accordion">match request by not matching body with xpath</button>
<div class="panel">
    <p>Matches if at least one value is returned by the JsonPath expression</p>
    <p>For a quick summary the XPath syntax please see <a target="_blank" href="https://www.w3schools.com/xml/xpath_syntax.asp" rel="noopener noreferrer">w3schools</a>, for details of the full XPath syntax please see <a target="_blank" href="https://www.w3.org/TR/1999/REC-xpath-19991116/#path-abbrev" rel="noopener noreferrer">www.w3.org</a></p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                // matches any request with an XML body that does NOT
                // contain one or more elements that match the XPath expression
                not(xpath("/bookstore/book[price>30]/price"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            // matches any request with an XML body that does NOT
            // contain one or more elements that match the XPath expression
            "not": true,
            "type": "XPATH",
            "xpath": "/bookstore/book[price>30]/price"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "not" : true,
      "type" : "XPATH",
      "xpath" : "/bookstore/book[price>30]/price"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_xml" class="accordion">match request by body with xml</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                xml(&quot;&lt;bookstore&gt;&quot; + System.lineSeparator() +
                    &quot;   &lt;book nationality=\&quot;ITALIAN\&quot; category=\&quot;COOKING\&quot;&gt;&quot; + System.lineSeparator() +
                    &quot;       &lt;title lang=\&quot;en\&quot;&gt;Everyday Italian&lt;/title&gt;&quot; + System.lineSeparator() +
                    &quot;       &lt;author&gt;Giada De Laurentiis&lt;/author&gt;&quot; + System.lineSeparator() +
                    &quot;       &lt;year&gt;2005&lt;/year&gt;&quot; + System.lineSeparator() +
                    &quot;       &lt;price&gt;30.00&lt;/price&gt;&quot; + System.lineSeparator() +
                    &quot;   &lt;/book&gt;&quot; + System.lineSeparator() +
                    &quot;&lt;/bookstore&gt;&quot;)
            )
    )
    .respond(
        response()
            .withBody(&quot;some_response_body&quot;)
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient(&quot;localhost&quot;, 1080).mockAnyResponse({
    &quot;httpRequest&quot;: {
        &quot;body&quot;: {
            &quot;type&quot;: &quot;XML&quot;,
            &quot;xml&quot;:  &quot;&lt;bookstore&gt;\n&quot; +
                    &quot;   &lt;book nationality=\&quot;ITALIAN\&quot; category=\&quot;COOKING\&quot;&gt;\n&quot; +
                    &quot;       &lt;title lang=\&quot;en\&quot;&gt;Everyday Italian&lt;/title&gt;\n&quot; +
                    &quot;       &lt;author&gt;Giada De Laurentiis&lt;/author&gt;\n&quot; +
                    &quot;       &lt;year&gt;2005&lt;/year&gt;\n&quot; +
                    &quot;       &lt;price&gt;30.00&lt;/price&gt;\n&quot; +
                    &quot;   &lt;/book&gt;\n&quot; +
                    &quot;&lt;/bookstore&gt;&quot;
        }
    },
    &quot;httpResponse&quot;: {
        &quot;body&quot;: &quot;some_response_body&quot;
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  &quot;httpRequest&quot; : {
    &quot;body&quot; : {
      &quot;type&quot; : &quot;XML&quot;,
      &quot;xml&quot; : &quot;&lt;bookstore&gt; &lt;book nationality=\&quot;ITALIAN\&quot; category=\&quot;COOKING\&quot;&gt;&lt;title lang=\&quot;en\&quot;&gt;Everyday Italian&lt;/title&gt;&lt;author&gt;Giada De Laurentiis&lt;/author&gt;&lt;year&gt;2005&lt;/year&gt;&lt;price&gt;30.00&lt;/price&gt;&lt;/book&gt; &lt;/bookstore&gt;&quot;
    }
  },
  &quot;httpResponse&quot; : {
    &quot;body&quot; : &quot;some_response_body&quot;
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_xml_placeholders" class="accordion">match request by body with xml using placeholders</button>
<div class="panel">
    <p>See <a target="_blank" href="https://github.com/xmlunit/user-guide/wiki/Placeholders" rel="noopener noreferrer">XMLUnit documentation</a> for full details of supported placeholders.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                xml("&lt;bookstore&gt;" + System.lineSeparator() +
                    "   &lt;book nationality=\"ITALIAN\" category=\"COOKING\"&gt;" + System.lineSeparator() +
                    "       &lt;title lang=\"en\"&gt;Everyday Italian&lt;/title&gt;" + System.lineSeparator() +
                    "       &lt;author&gt;${xmlunit.ignore}&lt;/author&gt;" + System.lineSeparator() +
                    "       &lt;year&gt;${xmlunit.isNumber}&lt;/year&gt;" + System.lineSeparator() +
                    "       &lt;price&gt;30.00&lt;/price&gt;" + System.lineSeparator() +
                    "   &lt;/book&gt;" + System.lineSeparator() +
                    "&lt;/bookstore&gt;")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest" : {
        "body" : {
            "type" : "XML",
            "xml" : "&lt;bookstore&gt;\n" +
                "   &lt;book nationality=\"ITALIAN\" category=\"COOKING\"&gt;\n" +
                "       &lt;title lang=\"en\"&gt;Everyday Italian&lt;/title&gt;\n" +
                "       &lt;author&gt;${xmlunit.ignore}&lt;/author&gt;\n" +
                "       &lt;year&gt;${xmlunit.isNumber}&lt;/year&gt;\n" +
                "       &lt;price&gt;30.00&lt;/price&gt;\n" +
                "   &lt;/book&gt;\n" +
                "&lt;/bookstore&gt;"
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest" : {
        "body" : {
            "type" : "XML",
            "xml" : "&lt;bookstore&gt;\n   &lt;book nationality=\"ITALIAN\" category=\"COOKING\"&gt;\n       &lt;title lang=\"en\"&gt;Everyday Italian&lt;/title&gt;\n       &lt;author&gt;${xmlunit.ignore}&lt;/author&gt;\n       &lt;year&gt;${xmlunit.isNumber}&lt;/year&gt;\n       &lt;price&gt;30.00&lt;/price&gt;\n   &lt;/book&gt;\n&lt;/bookstore&gt;"
        }
    },
    "httpResponse" : {
        "body" : "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_xml_schema" class="accordion">match request by body with xml schema</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                xmlSchema(&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;&quot; + System.lineSeparator() +
                    &quot;&lt;xs:schema xmlns:xs=\&quot;http://www.w3.org/2001/XMLSchema\&quot; elementFormDefault=\&quot;qualified\&quot; attributeFormDefault=\&quot;unqualified\&quot;&gt;&quot; + System.lineSeparator() +
                    &quot;    &lt;!-- XML Schema Generated from XML Document on Wed Jun 28 2017 21:52:45 GMT+0100 (BST) --&gt;&quot; + System.lineSeparator() +
                    &quot;    &lt;!-- with XmlGrid.net Free Online Service http://xmlgrid.net --&gt;&quot; + System.lineSeparator() +
                    &quot;    &lt;xs:element name=\&quot;notes\&quot;&gt;&quot; + System.lineSeparator() +
                    &quot;        &lt;xs:complexType&gt;&quot; + System.lineSeparator() +
                    &quot;            &lt;xs:sequence&gt;&quot; + System.lineSeparator() +
                    &quot;                &lt;xs:element name=\&quot;note\&quot; maxOccurs=\&quot;unbounded\&quot;&gt;&quot; + System.lineSeparator() +
                    &quot;                    &lt;xs:complexType&gt;&quot; + System.lineSeparator() +
                    &quot;                        &lt;xs:sequence&gt;&quot; + System.lineSeparator() +
                    &quot;                            &lt;xs:element name=\&quot;to\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;                            &lt;xs:element name=\&quot;from\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;                            &lt;xs:element name=\&quot;heading\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;                            &lt;xs:element name=\&quot;body\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;                        &lt;/xs:sequence&gt;&quot; + System.lineSeparator() +
                    &quot;                    &lt;/xs:complexType&gt;&quot; + System.lineSeparator() +
                    &quot;                &lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;            &lt;/xs:sequence&gt;&quot; + System.lineSeparator() +
                    &quot;        &lt;/xs:complexType&gt;&quot; + System.lineSeparator() +
                    &quot;    &lt;/xs:element&gt;&quot; + System.lineSeparator() +
                    &quot;&lt;/xs:schema&gt;&quot;)
            )
    )
    .respond(
        response()
            .withBody(&quot;some_response_body&quot;)
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient(&quot;localhost&quot;, 1080).mockAnyResponse({
    &quot;httpRequest&quot;: {
        &quot;body&quot;: {
            &quot;type&quot;: &quot;XML_SCHEMA&quot;,
            &quot;xmlSchema&quot;: &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\n&lt;xs:schema xmlns:xs=\&quot;http://www.w3.org/2001/XMLSchema\&quot; elementFormDefault=\&quot;qualified\&quot; attributeFormDefault=\&quot;unqualified\&quot;&gt;\n&quot; +
            &quot;    &lt;!-- XML Schema Generated from XML Document on Wed Jun 28 2017 21:52:45 GMT+0100 (BST) --&gt;\n&quot; +
            &quot;    &lt;!-- with XmlGrid.net Free Online Service http://xmlgrid.net --&gt;\n&quot; +
            &quot;    &lt;xs:element name=\&quot;notes\&quot;&gt;\n&quot; +
            &quot;        &lt;xs:complexType&gt;\n&quot; +
            &quot;            &lt;xs:sequence&gt;\n&quot; +
            &quot;                &lt;xs:element name=\&quot;note\&quot; maxOccurs=\&quot;unbounded\&quot;&gt;\n&quot; +
            &quot;                    &lt;xs:complexType&gt;\n&quot; +
            &quot;                        &lt;xs:sequence&gt;\n&quot; +
            &quot;                            &lt;xs:element name=\&quot;to\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;\n&quot; +
            &quot;                            &lt;xs:element name=\&quot;from\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;\n&quot; +
            &quot;                            &lt;xs:element name=\&quot;heading\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;\n&quot; +
            &quot;                            &lt;xs:element name=\&quot;body\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt;\n&quot; +
            &quot;                        &lt;/xs:sequence&gt;\n&quot; +
            &quot;                    &lt;/xs:complexType&gt;\n&quot; +
            &quot;                &lt;/xs:element&gt;\n&quot; +
            &quot;            &lt;/xs:sequence&gt;\n&quot; +
            &quot;        &lt;/xs:complexType&gt;\n&quot; +
            &quot;    &lt;/xs:element&gt;\n&lt;/xs:schema&gt;&quot;
        }
    },
    &quot;httpResponse&quot;: {
        &quot;body&quot;: &quot;some_response_body&quot;
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  &quot;httpRequest&quot; : {
    &quot;body&quot; : {
      &quot;type&quot; : &quot;XML_SCHEMA&quot;,
      &quot;xmlSchema&quot; : &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt; &lt;xs:schema xmlns:xs=\&quot;http://www.w3.org/2001/XMLSchema\&quot; elementFormDefault=\&quot;qualified\&quot; attributeFormDefault=\&quot;unqualified\&quot;&gt; &lt;xs:element name=\&quot;notes\&quot;&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name=\&quot;note\&quot; maxOccurs=\&quot;unbounded\&quot;&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name=\&quot;to\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt; &lt;xs:element name=\&quot;from\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt; &lt;xs:element name=\&quot;heading\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt; &lt;xs:element name=\&quot;body\&quot; minOccurs=\&quot;1\&quot; maxOccurs=\&quot;1\&quot; type=\&quot;xs:string\&quot;&gt;&lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt;&quot;
    }
  },
  &quot;httpResponse&quot; : {
    &quot;body&quot; : &quot;some_response_body&quot;
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_xml_schema_by_classpath" class="accordion">match request by body with xml schema by classpath</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                xmlSchemaFromResource("org/mockserver/examples/mockserver/testXmlSchema.xsd")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
</div>
<button id="button_match_request_by_body_with_json_exactly" class="accordion">match request by body with json exactly</button>
<div class="panel">
    <p>JSON body matcher supports two mode <strong>STRICT</strong> which matches all fields, order of arrays and no additional fields allowed, and <strong>ONLY_MATCHING_FIELDS</strong> which only matches fields provided in the request
        matcher.</p>
    <p>When matching JSON arrays the number of elements in the array must always match, however if <strong>ONLY_MATCHING_FIELDS</strong> mode is specified only the fields in the each array element in the matcher will be matched against each
        corresponding object in the array.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                json("{" + System.lineSeparator() +
                        "    \"id\": 1," + System.lineSeparator() +
                        "    \"name\": \"A green door\"," + System.lineSeparator() +
                        "    \"price\": 12.50," + System.lineSeparator() +
                        "    \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
                        "}",
                    MatchType.STRICT
                )
            )
    )
    .respond(
        response()
            .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "type": "JSON",
            "json": {
                "id": 1,
                "name": "A green door",
                "price": 12.50,
                "tags": ["home", "green"]
            },
            "matchType": "STRICT"
        }
    },
    "httpResponse": {
        "statusCode": 202,
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "body": {
            "type": "JSON",
            "json": {
                "id": 1,
                "name": "A green door",
                "price": 12.50,
                "tags": ["home", "green"]
            },
            "matchType": "STRICT"
        }
    },
    "httpResponse": {
        "statusCode": 202,
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_ignoring_extra_fields" class="accordion">match request by body with json ignoring extra fields</button>
<div class="panel">
    <p>JSON body matcher supports two mode <strong>STRICT</strong> which matches all fields, order of arrays and no additional fields allowed, and <strong>ONLY_MATCHING_FIELDS</strong> which only matches fields provided in the request
        matcher.</p>
    <p>When matching JSON arrays the number of elements in the array must always match, however if <strong>ONLY_MATCHING_FIELDS</strong> mode is specified only the fields in the each array element in the matcher will be matched against each
        corresponding object in the array.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                json("{" + System.lineSeparator() +
                        "    \"id\": 1," + System.lineSeparator() +
                        "    \"name\": \"A green door\"," + System.lineSeparator() +
                        "    \"price\": 12.50," + System.lineSeparator() +
                        "    \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
                        "}",
                    MatchType.ONLY_MATCHING_FIELDS
                )
            )
    )
    .respond(
        response()
            .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "id": 1,
            "name": "A green door",
            "price": 12.50,
            "tags": ["home", "green"]
        }
    },
    "httpResponse": {
        "statusCode": 202,
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "body": {
            "id": 1,
            "name": "A green door",
            "price": 12.50,
            "tags": ["home", "green"]
        }
    },
    "httpResponse": {
        "statusCode": 202,
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_ignoring_extra_fields_in_array" class="accordion">match request by body with json ignoring extra fields in array objects</button>
<div class="panel">
    <p>JSON body matcher supports two mode <strong>STRICT</strong> which matches all fields, order of arrays and no additional fields allowed, and <strong>ONLY_MATCHING_FIELDS</strong> which only matches fields provided in the request
        matcher.</p>
    <p>When matching JSON arrays the number of elements in the array must always match, however if <strong>ONLY_MATCHING_FIELDS</strong> mode is specified only the fields in the each array element in the matcher will be matched against each
        corresponding object in the array.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                json(
                    "{\"context\": [{\"source\": \"DECISION_REQUEST\"},{\"source\": \"DECISION_REQUEST\"},{\"source\": \"DECISION_REQUEST\"}]}",
                    MatchType.ONLY_MATCHING_FIELDS
                )
            )
    )
    .respond(
        response()
            .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "POST",
        "path": "/json",
        "body": {
            "type": "JSON",
            "json": {
                "context": [
                    {
                        "source": "DECISION_REQUEST"
                    },
                    {
                        "source": "DECISION_REQUEST"
                    },
                    {
                        "source": "DECISION_REQUEST"
                    }
                ]
            },
            "matchType": "ONLY_MATCHING_FIELDS"
        }
    },
    "httpResponse": {
        "statusCode": 200,
        "body": "some response"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "method": "POST",
        "path": "/json",
        "body": {
            "type": "JSON",
            "json": {
                "context": [
                    {
                        "source": "DECISION_REQUEST"
                    },
                    {
                        "source": "DECISION_REQUEST"
                    },
                    {
                        "source": "DECISION_REQUEST"
                    }
                ]
            },
            "matchType": "ONLY_MATCHING_FIELDS"
        }
    },
    "httpResponse": {
        "statusCode": 200,
        "body": "some response"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_placeholders" class="accordion">match request by body with json using placeholders</button>
<div class="panel">
    <p>See <a target="_blank" href="https://github.com/lukas-krecan/JsonUnit" rel="noopener noreferrer">JSONUnit documentation</a> for full details of supported placeholders.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                json("{" + System.lineSeparator() +
                        "    \"id\": 1," + System.lineSeparator() +
                        "    \"name\": \"A green door\"," + System.lineSeparator() +
                        "    \"price\": \"${json-unit.ignore-element}\"," + System.lineSeparator() +
                        "    \"enabled\": \"${json-unit.any-boolean}\"," + System.lineSeparator() +
                        "    \"tags\": [\"home\", \"green\"]" + System.lineSeparator() +
                        "}",
                    MatchType.ONLY_MATCHING_FIELDS
                )
            )
    )
    .respond(
        response()
            .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest" : {
        "body" : {
            "type" : "JSON",
            "json" : {
                "id" : 1,
                "name" : "A green door",
                "price" : "${json-unit.ignore-element}",
                "enabled" : "${json-unit.any-boolean}",
                "tags" : [ "home", "green" ]
            }
        }
    },
    "httpResponse" : {
        "statusCode" : 202,
        "body" : "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest" : {
        "body" : {
            "type" : "JSON",
            "json" : {
                "id" : 1,
                "name" : "A green door",
                "price" : "${json-unit.ignore-element}",
                "enabled" : "${json-unit.any-boolean}",
                "tags" : [ "home", "green" ]
            }
        }
    },
    "httpResponse" : {
        "statusCode" : 202,
        "body" : "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_lax_numbers" class="accordion">match request by body with json matching numbers regardless of type</button>
<div class="panel">
    <p>By default, JSON body matching treats <strong>1</strong> and <strong>1.0</strong> as different values because they have different numeric types (integer vs double). When <strong>matchNumbersAsStrings</strong> is set to <strong>true</strong>, numbers are compared by numeric value so <strong>1</strong>, <strong>1.0</strong> and <strong>1.00</strong> are all considered equal. This is useful when different languages or serializers produce different numeric representations for the same value.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                json("{" + System.lineSeparator() +
                        "    \"id\": 1," + System.lineSeparator() +
                        "    \"price\": 12.5" + System.lineSeparator() +
                        "}",
                    MatchType.ONLY_MATCHING_FIELDS,
                    true // matchNumbersAsStrings
                )
            )
    )
    .respond(
        response()
            .withStatusCode(HttpStatusCode.ACCEPTED_202.code())
            .withBody("some_response_body")
    );</code></pre>
        <p>This expectation will match requests containing <strong>{"id": 1.0, "price": 12.50}</strong> as well as <strong>{"id": 1, "price": 12.5}</strong>.</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "body": {
            "type": "JSON",
            "json": {
                "id": 1,
                "price": 12.5
            },
            "matchNumbersAsStrings": true
        }
    },
    "httpResponse": {
        "statusCode": 202,
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_schema" class="accordion">match request by body with json schema</button>
<div class="panel">
    <p>For details of the full json schema supported please see <a target="_blank" href="https://json-schema.org/" rel="noopener noreferrer">json-schema.org</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                jsonSchema("{" + System.lineSeparator() +
                    "    \"$schema\": \"https://json-schema.org/draft-04/schema#\"," + System.lineSeparator() +
                    "    \"title\": \"Product\"," + System.lineSeparator() +
                    "    \"description\": \"A product from Acme catalog\"," + System.lineSeparator() +
                    "    \"type\": \"object\"," + System.lineSeparator() +
                    "    \"properties\": {" + System.lineSeparator() +
                    "        \"id\": {" + System.lineSeparator() +
                    "            \"description\": \"The unique identifier for a product\"," + System.lineSeparator() +
                    "            \"type\": \"integer\"" + System.lineSeparator() +
                    "        }," + System.lineSeparator() +
                    "        \"name\": {" + System.lineSeparator() +
                    "            \"description\": \"Name of the product\"," + System.lineSeparator() +
                    "            \"type\": \"string\"" + System.lineSeparator() +
                    "        }," + System.lineSeparator() +
                    "        \"price\": {" + System.lineSeparator() +
                    "            \"type\": \"number\"," + System.lineSeparator() +
                    "            \"minimum\": 0," + System.lineSeparator() +
                    "            \"exclusiveMinimum\": true" + System.lineSeparator() +
                    "        }," + System.lineSeparator() +
                    "        \"tags\": {" + System.lineSeparator() +
                    "            \"type\": \"array\"," + System.lineSeparator() +
                    "            \"items\": {" + System.lineSeparator() +
                    "                \"type\": \"string\"" + System.lineSeparator() +
                    "            }," + System.lineSeparator() +
                    "            \"minItems\": 1," + System.lineSeparator() +
                    "            \"uniqueItems\": true" + System.lineSeparator() +
                    "        }" + System.lineSeparator() +
                    "    }," + System.lineSeparator() +
                    "    \"required\": [\"id\", \"name\", \"price\"]" + System.lineSeparator() +
                    "}"))
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            "type": "JSON_SCHEMA",
            "jsonSchema": {
                "$schema": "https://json-schema.org/draft-04/schema#",
                "title": "Product",
                "description": "A product from Acme catalog",
                "type": "object",
                "properties": {
                    "id": {
                        "description": "The unique identifier for a product",
                        "type": "integer"
                    },
                    "name": {
                        "description": "Name of the product",
                        "type": "string"
                    },
                    "price": {
                        "type": "number",
                        "minimum": 0,
                        "exclusiveMinimum": true
                    },
                    "tags": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "minItems": 1,
                        "uniqueItems": true
                    }
                },
                "required": [
                    "id",
                    "name",
                    "price"
                ]
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "body": {
            "type": "JSON_SCHEMA",
            "jsonSchema": {
                "$schema": "https://json-schema.org/draft-04/schema#",
                "title": "Product",
                "description": "A product from Acme catalog",
                "type": "object",
                "properties": {
                    "id": {
                        "description": "The unique identifier for a product",
                        "type": "integer"
                    },
                    "name": {
                        "description": "Name of the product",
                        "type": "string"
                    },
                    "price": {
                        "type": "number",
                        "minimum": 0,
                        "exclusiveMinimum": true
                    },
                    "tags": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "minItems": 1,
                        "uniqueItems": true
                    }
                },
                "required": [
                    "id",
                    "name",
                    "price"
                ]
            }
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_body_with_json_path" class="accordion">match request by body with jsonpath</button>
<div class="panel">
    <p>Matches if at least one value is returned by the JsonPath expression. For details of the full JsonPath supported please see <a target="_blank" href="https://github.com/json-path/JsonPath" rel="noopener noreferrer">github.com/json-path/JsonPath</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                // matches any request with an JSON body that contain
                // one or more fields that match the JsonPath expression
                jsonPath("$.store.book[?(@.price < 10)]")
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            // matches any request with an JSON body that contain
            // one or more fields that match the JsonPath expression
            "type": "JSON_PATH",
            "jsonPath": "$.store.book[?(@.price < 10)]"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "type": "JSON_PATH",
      "jsonPath": "$.store.book[?(@.price < 10)]"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_not_matching_body_with_json_path" class="accordion">match request by not matching body with JsonPath</button>
<div class="panel">
    <p>Matches if at least one value is returned by the JsonPath expression. For details of the full JsonPath supported please see <a target="_blank" href="https://github.com/json-path/JsonPath" rel="noopener noreferrer">github.com/json-path/JsonPath</a>.</p>
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .when(
        request()
            .withBody(
                // matches any request with an JSON body that does NOT contain
                // one or more fields that match the JsonPath expression
                not(jsonPath("$.store.book[?(@.price < 10)]"))
            )
    )
    .respond(
        response()
            .withBody("some_response_body")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "body": {
            // matches any request with an JSON body that does NOT contain
            // one or more fields that match the JsonPath expression
            "not": true,
            "type": "JSON_PATH",
            "jsonPath": "$.store.book[?(@.price < 10)]"
        }
    },
    "httpResponse": {
        "body": "some_response_body"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "httpRequest" : {
    "body" : {
      "not": true,
      "type": "JSON_PATH",
      "jsonPath": "$.store.book[?(@.price < 10)]"
    }
  },
  "httpResponse" : {
    "body" : "some_response_body"
  }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_by_binary_body" class="accordion">match request with binary PNG body</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">byte[] pngBytes = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("org/mockserver/examples/mockserver/test.png"));
new MockServerClient("localhost", 1080)
    .when(
        request()
            .withMethod("POST")
            .withHeaders(
                header("content-type", "image/png"),
                header("content-disposition", "form-data; name=\"test.png\"; filename=\"test.png\"")
            )
            .withBody(binary(pngBytes))
    )
    .respond(
        response()
            .withBody("png_saved_response")
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "httpRequest": {
        "method": "POST"
        "headers": {
            "content-type": ["image/png"],
            "content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
        },
        "body": {
            "type": "BINARY",
            "base64Bytes": " "
        }
    },
    "httpResponse" : {
        "body" : "png_saved_response"
    }
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
    "httpRequest": {
        "method": "POST"
        "headers": {
            "content-type": ["image/png"],
            "content-disposition": ["form-data; name=\"test.png\"; filename=\"test.png\""]
        },
        "body": {
            "type": "BINARY",
            "base64Bytes": " "
        }
    },
    "httpResponse" : {
        "body" : "png_saved_response"
    }
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.9.x#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
<button id="button_match_request_update_by_id" class="accordion">update expectation by id</button>
<div class="panel">
    <button class="accordion inner">Java</button>
    <div class="panel">
        <pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
    .upsert(
        new Expectation(
            request().withPath("/some/path"),
            Times.once(),
            TimeToLive.exactly(TimeUnit.SECONDS, 60L),
            100
        )
        .withId("some_unique_id")
        .thenRespond(response().withBody("some_response_body"))
    );</code></pre>
    </div>
    <button class="accordion inner">JavaScript</button>
    <div class="panel">
        <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).mockAnyResponse({
    "id": "some_unique_id",
    "httpRequest": {
        "path": "/some/path"
    },
    "httpResponse": {
        "body": "some_response_body"
    },
    "times": {
        "remainingTimes": 1,
        "unlimited": false
    },
    "timeToLive": {
        "timeUnit": "SECONDS",
        "timeToLive": 60,
        "unlimited": false
    },
    "priority" : 100
}).then(
    function () {
        console.log("expectation created");
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
    <button class="accordion inner">REST API</button>
    <div class="panel">
        <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
  "id": "some_unique_id",
  "httpRequest" : {
    "path" : "/some/path"
  },
  "httpResponse" : {
    "body" : "some_response_body"
  },
  "times" : {
    "remainingTimes" : 1,
    "unlimited" : false
  },
  "timeToLive" : {
    "timeUnit" : "SECONDS",
    "timeToLive" : 60,
    "unlimited" : false
  },
  "priority" : 100
}'</code></pre>
        <p>See <a  href="https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/{{ site.mockserver_api_version }}#/expectation/put_expectation" target="_blank" rel="noopener noreferrer">REST API</a> for full JSON specification</p>
    </div>
</div>
