Importing
To import any of the supported formats (Swagger, OpenAPI, WireMock Cloud WireMock JSON), execute aPOST request to the stub import URL e.g.:
Asynchronous imports
Larger imports can take a while to process, so every import runs as a background job. When you call the import endpoint it will wait up to a configurable sync timeout (3 seconds by default) for the import to finish:- If the import finishes within the timeout, a
200is returned containing the import result directly i.e. the IDs of the stub mappings created. - If the import is still running when the timeout elapses, a
202 Acceptedresponse is returned containing details of the running job:
GET request to the URL in the job’s links.self:
status will become COMPLETE, and its outcome
will contain the import result:
status will become ERROR, and its outcome will
contain the errors.
Note that if you’re using the api.wiremock.cloud endpoint instead of your mock API’s own
domain, the returned links.self URL will be of the form
/v1/mock-apis/{mockApiId}/jobs/{jobId}, but the behaviour is otherwise identical.
Setting the sync timeout
The sync timeout can be changed - or disabled entirely - by supplying an import config in aconfig part of a multipart request, with the syncTimeout set to an
ISO 8601 duration:
syncTimeout to PT0S will disable waiting entirely - the endpoint will return
a 202 immediately, and you can poll the job for the result. Other import config options
such as duplicatePolicy can be supplied in the same config part.
More detail can be found in our API reference
and the job status API reference.
Exporting in WireMock Cloud/WireMock JSON format
To export an API’s stubs, execute aGET request to the stub mappings admin URL e.g.: