Prepare OpenAPI specifications you want to mock in __unmock__ folder. For example, to mock api.github.com:
# Prepare directory
mkdir -p __unmock__/githubv3
# Write openapi.yaml to the directory
wget https://raw.githubusercontent.com/unmock/golang-example/master/__unmock__/githubv3/openapi.yaml -O __unmock__/githubv3/openapi.yaml
Run unmock-server image, mounting __unmock__ folder you just prepared:
docker run -d --rm -p 8000:8000 -p 8008:8008 -p 8443:8443 -v $(pwd)/__unmock__:/app/__unmock__ --name unmock-server unmock/unmock-server
To mock HTTPS APIs, Unmock generates a self-signed certificate for the signed domain on the fly. Because the certificate is not signed by your root CA, your HTTP client will fail the call (and that's good).
To use Unmock with HTTPS, you need to
Fetch the Unmock certificate used for signing the certificates
wget https://raw.githubusercontent.com/unmock/unmock-js/dev/packages/unmock-server/certs/ca.pem
Trust the certificate when using Unmock
For cURL, you would set
SSL_CERT_FILE=ca.pem, orCURL_CA_BUNDLE=ca.pem.
Make a call to api.github.com with curl using the proxy server:
https_proxy=http://localhost:8008 SSL_CERT_FILE=ca.pem curl -i https://api.github.com/user/repos
docker stop unmock-server
Build image:
./build.sh
Run image:
./run.sh
Publish:
docker login
docker push unmock/unmock-server:<tag>
Content type
Image
Digest
Size
358.8 MB
Last updated
over 6 years ago
docker pull unmock/unmock-server