DEPRECATED: Wiremock extension for recording stub mappings
Java Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
wiremock @ da0cf44


An improved version of this extension was integrated into Wiremock 2.7, so it's no longer needed.


Build Status Maven Central

wiremock-snapshot is an admin extension for WireMock that adds a new endpoint, /__admin/recordings/snapshot, for creating stub mappings from recorded requests. It's an alternative to the Record and Playback feature that doesn't require restarting the server, and provides more customization options.

WARNING: This is currently alpha. Backwards compatibility is not guaranteed.


Run gradle jar to build the JAR without dependencies or gradle fatJar to build a standalone JAR. These will be placed in build/libs/.


Standalone server:

java -jar build/libs/wiremock-snapshot-standalone-0.3a.jar

With WireMock standalone JAR:

java \
        -cp wiremock-standalone.jar:build/libs/wiremock-snapshot-0.3a.jar \
        com.github.tomakehurst.wiremock.standalone.WireMockServerRunner \

Programmatically in Java:

new WireMockServer(wireMockConfig()


Creating proxy for recording

If you're using this as a replacement for the Record and Playback feature, you'll need to manually create the proxy mapping that's normally done automatically with the --proxy-all option. This can be done with by calling /__admin/mappings with the following stub mapping:

curl -d '{
    "response": {
        "proxyBaseUrl": ""
}' http://localhost:8080/__admin/mappings

Replace with the proxy base URL and http://localhost:8080 with the Wiremock base URL.

Calling the Snapshot API

The /__admin/recordings/snapshot endpoint can be accessed via POST and creates stub mappings from the requests and responses in the request journal. It accepts the following options:

  • "filters" - Request patterns and IDs to use for determining which requests for which to create stub mappings.
    • Possible values: Same request patterns accepted by /__admin/requests/find. See Request Matching for details. Also accepts an array of IDs to match against.
    • Default: no filtering.
  • "persist" - If set to true, persist stub mappings to disk. Otherwise, just output
    • Possible values: true, false
    • Default: true
  • "captureHeaders" - Header matchers for including headers in the StubMapping. The request is matched against each matcher, and the associated header is added to the stub mapping if there's a match.
  • "outputFormat" - Determines response body.
    • Possible values: "ids" to return array of stub mapping IDs, "full" to return array of stub mapping objects
    • Default: "full"
  • "repeatsAsScenarios" - Whether to record duplicate requests as scenarios, or just ignore them.
    • Possible values: true to use scenarios for duplicate requests, false to discard them
    • Default: false


  • Record mappings with defaults: curl -X POST http://localhost:8080/__admin/recordings/snapshot

  • Filter by URL and header values (i.e. only create stub mappings for matching requests) and output array of stub mappings:

      curl -d '{
          "outputFormat": "full",
          "filters": {
              "urlPattern": "/foo/(bar|baz)",
              "headers": {
                  "Content-Type": {
                      "equalTo": "application/json"
      }' http://localhost:8080/__admin/recordings/snapshot`
  • Filter by URL and IDs, and output array of stub mappings:

      curl -d '{
          "outputFormat": "full",
          "filters": {
      "ids": [
              "urlPattern": "/foo"
      }' http://localhost:8080/__admin/recordings/snapshot`
  • Always include "Content-Type" header in stub mapping, and include "Accept" header if it's equal to "bar".

       curl -d '{
          "captureHeaders": {
              "url": "/foo",
              "method": "ANY",
              "headers": {
                  "Content-Type": { "anything": true },
                  "Accept": { "equalTo": "Bar" }
       }' http://localhost:8080/__admin/recordings/snapshot`
  • Output an array IDs, without persisting.

       curl -d '{
          "persist": false,
          "outputFormat": "ids"
       }' http://localhost:8080/__admin/recordings/snapshot`