A lightweight, user-friendly, and powerful tool for mocking API endpoints.
997
A lightweight, user-friendly, and powerful tool for mocking API endpoints. Useful for testing API client integrations, or performance testing your application without sending traffic to your API dependencies. Has an external dependency to a mongo database.
Runs in port 3000 by default.
docker run -d --name supermockapi -p 80:3000 dsumiskum/supermockapi
Configure a different port.
docker run -d --name supermockapi -p 80:5000 -e "PORT:5000" dsumiskum/supermockapi
Specify initial mocked api routes specification through volume mapping a folder with a routes.json or the file itself to the container workdir (app is the workdir).
The application will look for a routes.json file in the workdir when booting up.
docker run -d --name supermockapi -p 3000:3000 -v "${pwd}/folder/routes.json:/app/routes.json" dsumiskum/supermockapi
Route specifications format (routes.json):
[
{
"path": "/product/:sku",
"method": "GET",
"status": 200,
"body": {
"message": "Server received your request for sku {sku}"
},
"responseDelay": 5000
},
{
"path": "/product/:sku",
"method": "POST",
"status": 500
}
]
Supermockapi is meant to be lightweight, easy to deploy, and works for your Continous Integration needs. A big problem with performance testing services is isolating the external dependencies to get more predictable metrics, which would be useful if you are benchmarking your metrics overtime.
With supermockapi, you can deploy it with your application as a stack, with specified routes.json file. And you can use the super friendly UI to manually add mock api endpoints. The UI comes with a console log stream, so that you can monitor incoming requests all in one place.
You can do this via the UI or by configuring a routes.json file. Json file example where you take a parameter sku in the base path:
{
"path": "/product/:sku"
}
You can do this via the UI or by configuring a routes.json file. Json file example for returning a 200:
{
"path": "/product/:sku",
"status": 200
}
You can do this via the UI or by configuring a routes.json file. Json file example for returning a simple message:
{
"path": "/product/:sku",
"status": 200,
"body": {
"message": "Hello world!"
}
}
You can include values from the tokens bag in your response body. The syntax for this is {token}.
{
"path": "/product/:sku",
"status": 200,
"body": {
"sku": "{sku}"
}
}
What is included in tokens:
{body}{calls}{random}{timestamp}You can do this via the UI or by configuring a routes.json file. Json file example for delaying response by 5 seconds:
{
"responseDelay": 5000
}
You can do this via the UI or by configuring a routes.json file. Json file example of a weighted response scenario using conditional behaviors:
{
"path": "/random",
"method": "GET",
"status": 200,
"conditionalBehaviors": [{
"condition": "{random} <= 30",
"status": 500,
"body": {
"message": "[Condition Triggered] Random = {random}"
}
},
{
"condition": "{random} <= 60",
"status": 404,
"body": {
"message": "[Condition Triggered] Random = {random}"
}
},
{
"condition": "{random} <= 90",
"status": 200,
"body": {
"message": "[Condition Triggered] Random = {random}"
}
},
{
"condition": "{random} <= 100",
"status": 206,
"body": {
"message": "[Condition Triggered] Random = {random}"
}
}
],
"body": {
"message": "Number of calls = {calls}"
}
}
Content type
Image
Digest
Size
43.7 MB
Last updated
almost 9 years ago
docker pull dsumiskum/supermockapi