WireMock core and Studio share the same native JSON format for stubs, so mock APIs can be imported and exported between the two.
JSON exports can also be stored in source control, and used to clone or move stubs between WireMock APIs.
Importing a mock API into WireMock Studio from WireMock
Assuming you’re running a WireMock instance on port 8080, you can export all the stubs currently defined via the admin API:
curl --output example-stubs.json http://localhost:8080/__admin/mappings
Then to import into WireMock Studio, open the Import dialog and drop or upload the
A current limitation of this approach is that response bodies represented as files under the
__filesdirectory will not be imported. See how this can be worked around by uploading a WireMock project folder and via the WireMock Java API.
Importing a mock API into WireMock from WireMock Studio
First, export the stubs via the Export dialog in the Stubs page:
Then call the WireMock import API with the file you downloaded:
curl -v -d @example-stubs.json http://localhost:8080/__admin/mappings/import
Alternatively you can copy
example-stubs.json into the
under your WireMock root and either restart WireMock or make a
POST request to the
curl -v -X POST http://localhost:8080/__admin/mappings/reset
If any of your stubs make use of response templating then you’ll need to ensure WireMock is started with the
--local-response-templatingCLI parameter or Java equivalent.
It is not currently possible to import stubs that use the JWT and JWKS template helpers into WireMock.
Uploading a WireMock folder
If you have a WireMock project that consists of individual JSON stub mapping
files under the
mappings directory that refer to response body files under
you can import this by dragging and dropping the project folder into the dialog.
Unlike the method involving a single JSON file described above, this will cause the
response bodies under
__files to be inlined.
Pushing stubs to WireMock Studio using WireMock’s Java API
Another way to import a WireMock project that has a
__files directory is to push it using WireMock’s Java API.
This method also inlines response bodies before sending them to WireMock Studio:
WireMock wireMock = WireMock.create() // Change this if you're running WireMock Studio somewhere else .host("localhost") .port(8000) .build(); // The root directory of the WireMock project, // under which the mappings and __files directories should be found wireMock.loadMappingsFrom("/wiremock");