Skip to content

Micro-service that returns mock api responses across a number of endpoint spanning various verticals. Great for testing API gateways such as Kong, K8s, Service Mesh deployments, and CI/CD and devops pipelines.

License

Notifications You must be signed in to change notification settings

yesinteractive/mocktainer

Repository files navigation

Mocktainer.io

alt text

Docker Pulls GitHub stars GitHub release MIT

Mocktainer.io is a micro service that mocks micro service API's with fake data accross multiple endpoints representing various verticals and functions.

Hosted Service / Demo

Access http://mocktainer.io to try the free hosted service.

Usage

Endpoints:
  • / Root returns help and instructions in HTML format
  • /accounts Returns mock bank accounts in JSON
  • /customers Returns mock customers in JSON
  • /employees Returns mock employees in JSON
  • /inventory Returns mock product inventory in JSON
  • /orders Returns mock orders in JSON
  • /portfolio Returns mock investment portfolio in JSON
  • /prescriptions Returns mock drug prescriptions list in JSON
  • /trades Returns mock trades in JSON

Echo URI : Simply add /echo to the end of any endpoint above to echo back the original request with payload and request headers. Helpful for troublshooting.

Adding New Endpoints : See instructions below.

Methods Supported : GET PUT POST DELETE PATCH

Parameters : ?n=<number> to specify number of records to return. Default is 10. Max is 250.

Successful Response : 200 OK

{
  "Results":  {
                  ...
              }
  "Request":  {
                  ...
              },
}

Installation

Deployment Examples

See usage examples for Kubernetes, Kong for Kubernetes Ingress Controller, and docker-compose in the examples directory folder.

With Docker

Docker image is Alpine 3.11 based running PHP 7.3 on Apache. The container exposes both ports 80 an 443 with a self signed certificated. If you wish to alter the container configuration, feel free to use the Dockerfile in this repo (https://github.com/yesinteractive/mocktainer/blob/master/Dockerfile). Otherwise, you can pull the latest image from DockerHub with the following command:

docker pull yesinteractive/mocktainer

Typical basic usage (below example exposes mocktainer on host ports 8100 and 8143):

$ docker run -d \
  -p 8100:80 \
  -p 8143:443 \
  yesinteractive/mocktainer

Typical usage in Dockerfile:

FROM yesinteractive/mocktainer
RUN echo <your commands here>

Adding New Endpoints

Adding a new endpoint is as simple as adding a new CSV file in the endpoints directory. The name of the csv will be the dynamic endpoint. The first row must be column header names and there is no limit to the amount of columns. See examples in the controllers directory.

Contributing

If you have an endpoint to share, please add your submission via a pull request.