Each HTTP method configuration file looks like this:
{
"active": true,
"services": [
{
"active": true,
"path": "exampleEndpoint",
"file": "delete-result.example.json",
"delayBy": 5000
},
...
]
}
The main active switch can be used switch the whole mock configuration for the particular HTTP method on or off.
The services array holds the individual configuration for each server route which should be mocked.
The active switch is used to toggle the mocking of the individual route.
The path stores the route which should be mocked. It is a path relative to the serviceBasePath
of the server.root.json
.
The JSON file which has to be returned if the route is called. The file name will be resolved relative to mock
path specified in the filesystem.path.json
followed by the HTTP method name. E.g. file
is set to "delete-result.example.json"
, mock
is set to "example-mocks"
and the configuration file is DELETE.mock.json
then the application will return example-mocks/DELETE/delete-result.example.json
.
The file
property can be left out if the HTTP response should contain no body.
The amount time (in milliseconds) which passes before the file is returned.
A route can not only return a static mock file but is also able to return any HTTP code. This is configured by adding the optional status
property in which the HTTP code can be specified:
{
"active": true,
"services": [
{
"active": true,
"path": "exampleEndpoint",
"file": "delete-result.error.json",
"delayBy": 5000,
"status": 500
}
]
}