Skip to main content

specmatic for local apis

For better local development against APIs one option is to use Specmatic in order to mock.

It is achieved very easily via Docker.

There is a caveat that you are relying on the consuming API to have produced a workable / meaningful contract.

Steps:

mkdir specmatic-demo
cd specmatic-demo
touch openapi.yaml
nano openapi.yaml

Here you will want to obtain an Open API contract from the consumer. Paste and save.

docker run -v "$(pwd)/openapi.yaml:/openapi.yaml" -p "9001:9000" specmatic/specmatic mock "/openapi.yaml"
note

Some more info can be found on the Specmatic site here