- Request properties matcher — matches by HTTP properties such as method, path, headers, query parameters, cookies, and body
- OpenAPI matcher — matches against an OpenAPI v3 specification (see OpenAPI)
! (in JSON/REST) or wrap it with not() (in Java) to negate it. Prefix a key with ? to make it optional.
Method
- Java
- JavaScript
- REST API
GET:
- Java
- REST API
Path
Match an exact path, a regex, or negate it.- Java
- REST API
Path parameters
Use{paramName} placeholders in the path and specify values under pathParameters.
- Java
- JavaScript
- REST API
Query parameters
- Java
- JavaScript
- REST API
?:
"keyMatchStyle": "MATCHING_KEY" to require all values for a key to match.
Headers
- Java
- REST API
Cookies
Cookies follow the same pattern as headers but map each name to a single value.- Java
- REST API
? prefix:
Body
MockServer supports many body match types.Plain text (exact or substring)
Plain text (exact or substring)
Match exact body content:Match a substring using
subString: true:Regular expression
Regular expression
.withBody(regex("starts_with_.*"))JSON (strict or partial)
JSON (strict or partial)
Strict matching (all fields, array order, no extra fields):Partial matching — only the fields you specify must be present:Use JSONUnit placeholders to ignore fields or match by type:
JSON Schema
JSON Schema
JsonPath
JsonPath
Matches if at least one value is returned by the expression:
XPath
XPath
Matches if at least one node is returned by the expression:In Java:
.withBody(xpath("/bookstore/book[price>30]/price"))Negate the XPath match:XML (exact or with placeholders)
XML (exact or with placeholders)
Exact XML match:Use XMLUnit placeholders to ignore elements or match by type:
XML Schema
XML Schema
Form fields (URL-encoded)
Form fields (URL-encoded)
Negation
Prefix any string value with! in JSON/REST to negate it. In Java, wrap it with not():