Administration REST API
plugin-admin-api
The main distribution includes the plugin-admin-api plugin preinstalled, which provides a REST API that allows to change dynamically the current behavior, change delay time, and another Mocks Server options .
This is very useful when running acceptance tests, as you can change the behavior of the api simply with a request in your tests before
method, for example.
A client for the administration api is also distributed as a separated package: @mocks-server/admin-api-client.
Options
adminApiPath
:<String>
Path for the administration api. Default is "/admin". You should change it only in case there is any conflict with the api you are mocking.adminApiDeprecatedPaths
-<Boolean>
Disables the deprecated "/mocks" api path, which is still enabled by default due to backward compatibility. Used as command line argument, you can disable it using--no-adminApiDeprecatedPaths
(Read the command-line-arguments chapter for further info)
Api resources
Available api resources are:
GET
/admin/about
Returns "plugin-admin-api" information.- Response body example:
{ "version": "1.2.0" }
- Response body example:
GET
/admin/behaviors
Returns behaviors collection.GET
/admin/behaviors/:id
Returns an specific behavior.GET
/admin/fixtures
Returns fixtures collection.GET
/admin/fixtures/:id
Returns an specific fixture.GET
/admin/settings
Returns current server settings.- Response body example:
{ "delay": 0, behavior: "foo-behavior", path: "mocks" }
- Response body example:
PATCH
/admin/settings
Changes current server settings.- Request body example:
{ "delay": 3000 }
- Request body example:
GET
/admin/alerts
Returns current alerts.GET
/admin/alerts/:id
Returns an specific alert. The alertid
is equivalent to the alertcontext
.
Deprecated api resources under "/mocks" api path are also still available.