Mock APIs
Teams
Organisations
Data sources
Database connections
Usage
Access control
Stub Mappings
- GETGet all stub mappings
- POSTCreate a new stub mapping
- DELDelete all stub mappings
- POSTReset stub mappings
- POSTPersist stub mappings
- POSTImport stub mappings
- GETGet stub mapping by ID
- PUTUpdate a stub mapping
- DELDelete a stub mapping
- POSTFind stub mappings matching metadata
- POSTDelete stub mappings matching metadata
Requests
OpenAPI
Imports
Update a stub mapping
curl --request PUT \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/mappings/{stubMappingId} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}'
{
"id": "76ada7b0-49ae-4229-91c4-396a36f18e09",
"priority": 3,
"request": {
"headers": {
"Accept": {
"equalTo": "text/plain"
}
},
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}
Authorizations
Basic authentication header of the form Basic <encoded-value>
, where <encoded-value>
is the base64-encoded string username:password
.
Path Parameters
The ID of the Mock API
5 - 10
The UUID of stub mapping
Body
This stub mapping's unique identifier
Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
The stub mapping's name
The new state for the scenario to be updated to after this stub is served.
Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
A map of the names of post serve action extensions to trigger and their parameters.
This stub mapping's priority relative to others. 1 is highest.
x > 1
Require the state of the Mock API to match the provided patterns. More information on this feature can be found here.
require-state
The key of the item to match. Cannot be templated.
The context of the item to match. Can be templated.
The hostname part of the request URL
The HTTP request method e.g. GET
Multipart patterns to match against headers and body.
Determines whether all or any of the parts must match the criteria for an overall match.
ALL
, ANY
Path parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form. Can only be used when the urlPathPattern URL match type is in use and all keys must be present as variables in the path template.
The HTTP port number of the request URL
1 < x < 65535
The scheme (protocol) part of the request URL
http
, https
The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The required state of the scenario in order for this stub to be matched.
Extra request headers to send when proxying to another host.
A base64 encoded string used to describe binary data.
The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The fault to apply (instead of a full, valid response).
CONNECTION_RESET_BY_PEER
, EMPTY_RESPONSE
, MALFORMED_RESPONSE_CHUNK
, RANDOM_DATA_THEN_CLOSE
Number of milliseconds to delay be before sending the response.
Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The base URL of the target to proxy matching requests to.
A path segment to remove from the beginning in incoming request URL paths before proxying to the target.
Request headers to remove when proxying to another host.
The HTTP status code to be returned
The HTTP status message to be returned
Parameters to apply to response transformers.
List of names of transformers to apply to this response.
The name of the scenario that this stub mapping is part of
The list of serve event listeners
change-state
The key of the item to perform the operation on. Cannot be templated.
The operation to perform. * SET
- set the value of a state item in the state cache. * DELETE
- delete a state item from the state cache. * REQUEST_VAR
- set a variable that will be available for the lifetime of the request.
SET
, DELETE
, REQUEST_VAR
The context of the item to perform the operation on. Relevant only when operation
is SET
or DELETE
. Can be templated.
The value to set the item to. Relevant only when operation
is SET
or REQUEST_VAR
. Can be templated.
Alias for the id
Response
This stub mapping's unique identifier
Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
The stub mapping's name
The new state for the scenario to be updated to after this stub is served.
Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
A map of the names of post serve action extensions to trigger and their parameters.
This stub mapping's priority relative to others. 1 is highest.
x > 1
Require the state of the Mock API to match the provided patterns. More information on this feature can be found here.
require-state
The key of the item to match. Cannot be templated.
The context of the item to match. Can be templated.
The hostname part of the request URL
The HTTP request method e.g. GET
Multipart patterns to match against headers and body.
Determines whether all or any of the parts must match the criteria for an overall match.
ALL
, ANY
Path parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form. Can only be used when the urlPathPattern URL match type is in use and all keys must be present as variables in the path template.
The HTTP port number of the request URL
1 < x < 65535
The scheme (protocol) part of the request URL
http
, https
The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
The required state of the scenario in order for this stub to be matched.
Extra request headers to send when proxying to another host.
A base64 encoded string used to describe binary data.
The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The fault to apply (instead of a full, valid response).
CONNECTION_RESET_BY_PEER
, EMPTY_RESPONSE
, MALFORMED_RESPONSE_CHUNK
, RANDOM_DATA_THEN_CLOSE
Number of milliseconds to delay be before sending the response.
Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
The base URL of the target to proxy matching requests to.
A path segment to remove from the beginning in incoming request URL paths before proxying to the target.
Request headers to remove when proxying to another host.
The HTTP status code to be returned
The HTTP status message to be returned
Parameters to apply to response transformers.
List of names of transformers to apply to this response.
The name of the scenario that this stub mapping is part of
The list of serve event listeners
change-state
The key of the item to perform the operation on. Cannot be templated.
The operation to perform. * SET
- set the value of a state item in the state cache. * DELETE
- delete a state item from the state cache. * REQUEST_VAR
- set a variable that will be available for the lifetime of the request.
SET
, DELETE
, REQUEST_VAR
The context of the item to perform the operation on. Relevant only when operation
is SET
or DELETE
. Can be templated.
The value to set the item to. Relevant only when operation
is SET
or REQUEST_VAR
. Can be templated.
Alias for the id
curl --request PUT \
--url https://wmc.wiremockapi.cloud/v1/mock-apis/{mockApiId}/mappings/{stubMappingId} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}'
{
"id": "76ada7b0-49ae-4229-91c4-396a36f18e09",
"priority": 3,
"request": {
"headers": {
"Accept": {
"equalTo": "text/plain"
}
},
"method": "GET",
"url": "/some/thing"
},
"response": {
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
},
"status": 200
}
}