/wiremock-starter

Quick start for creating mocked APIs using Wiremock and docker-compose

Primary LanguageShellMIT LicenseMIT

Wiremock Starter

A simple example of how to stand-up one or more Wiremock servers on a development machine, using docker-compose, requiring only configuration files to be specified.

Getting started

  1. Run the init script to download pre-requisites
chmod u=rwx ./init.sh && ./init.sh
  1. Start up the servers
docker-compose up -d
  1. Test the endpoints

(jq is optionally used to pretty-print the response; omit if you don't like it.)

curl -s http://localhost:8090  | jq

curl -s http://localhost:8091  | jq

curl -s http://localhost:8090/ex1  | jq
  1. Stop the servers
docker-compose down

Usage

# start all servers in the background
docker-compose up -d

# restart all servers to honour any config changes
docker-compose restart

# delete all servers
docker-compose down
# or start all servers in the foreground
docker-compose up

# ctrl-c to stop
# start only one of the servers
docker-compose up server-a

Notes

Response Templating

To support response templating, an extension must be downloaded first. This is then bind-mounted into the container, and enabled via the command options.

See the docker-compose configuration for server-a for an example.

The ./init.sh script provided will download the required extension.

Logging Verbosity

Verbose logging can be enabled by passing in the --verbose parameter to the Wiremock server via the command option to docker.

See the docker-compose configuration for server-a for an example.

Any other command line parameters for Wiremock, detailed in the documentaiton can be added in the same way.

Resources