Simple API mock that will help to serve JSON response that's been defined in config (yaml) file
- Download the binary from GitHub Releases
- Extract to dir
api-mock/
mkdir api-mock tar -C api-mock -xzf api-mock_version_os_arch.tar.gz
- Create app config file.
Above app config will read json response in current directory with
cp app.yml.example app.yml
response.yml
as the config filename. - Create yaml file to define the endpoint along with their respective response
cp response.yml.example response.yml
- Run
./api-mock
- Hit endpoint
/api/v1/test
will return status code200
and json response like{ "messages": "data was found", "data": { "status": "okay", "detail": true }, "errors": null, "code": 200 }
- You can add another endpoint along with their json response as many as you want, and of course you does not need to restart the app since it support hot reload thanks to Viper
- Only support
JSON
response - Does not support auth. so anyone can hit the endpoint and get the JSON response
- Does not support any request validation (future development)
- Does not support giving multiple responses in single endpoint. say you want give response either
200
or400
according to request in single endpoint
This project is licensed under the MIT License - see the LICENSE file for details.