Quick start
json-mockr requires a configuration file. The minimum requirements are that you define the routes you want to mock. The application will make some assumptions on the resources you want and what ids to use.
Create a configuration file config.yaml with the routes you want to mock.
routes:
- path: "/users"
- path: "/users/{id}"
Start json-mockr with docker mounting the configuration file in the container and setting the file location
docker run -p 8080:8080 -v ${PWD}/config.yaml:/app/config.yaml \
-e JSON_MOCA_CONFIG_FILE=/app/config.yaml json-mockr:<version>
Execute a POST request
curl --request POST \
--url http://localhost:8080/users/ \
--header 'Content-Type: application/json' \
--data '
{
"name": "Peter",
"email": "pete@company.com"
}'
New resource is created with a generated ID
{
"id": "pkk0xV",
"name": "Peter",
"email": "pete@company.com"
}