apimocker
Version:
Simple HTTP server that returns mock service API responses to your front end.
144 lines (143 loc) • 4.11 kB
JSON
{
"note": "This is a sample config file. You should change the mockDirectory to a more reasonable path.",
"mockDirectory": "/file/system/path/to/apimocker/samplemocks/",
"staticDirectory": "/file/system/path/to/static/directory",
"staticPath": "/web/path/to/static/directory",
"quiet": false,
"port": "7878",
"latency": 50,
"logRequestHeaders": false,
"webServices": {
"first": {
"mockFile": "foo.json",
"latency": 20,
"verbs": ["get", "post"],
"responses": {
"get": {
"mockFile": "king.json"
},
"post": {
"mockFile": "ace.json"
}
}
},
"second": {
"verbs": ["delete", "post"],
"responses": {
"delete": {"httpStatus": 204},
"post": {
"contentType": "foobar",
"mockFile": "king.json"
}
}
},
"nested/ace": {
"mockFile": "ace.json",
"verbs": ["post", "get"],
"switch": "customerId"
},
"nested/ace2": {
"mockFile": "ace.json",
"verbs": ["post", "get"],
"switch": ["customerId","multitest"]
},
"var/:id/:color": {
"mockFile": "xml/queen.xml",
"verbs": ["all"],
"switch": ["id", "color"]
},
"login": {
"verbs": ["post"],
"switch": ["userId", "password"],
"responses": {
"post": {"httpStatus": 401, "mockFile": "sorry.json"}
},
"switchResponses": {
"userIduser1passwordgood": {"httpStatus": 200, "mockFile": "king.json"},
"userIdadminpasswordgood": {"httpStatus": 200}
}
},
"template/:name/:number" :{
"mockFile": "templateSample.json",
"enableTemplate": true,
"verbs":["get"],
"contentType":"application/json"
},
"templateSwitchGetParams" : {
"mockFile": "templateSwitchSample.json",
"verbs":["get"],
"templateSwitch": ["appID",
"appName",
"userName",
"userAge"],
"contentType": "application/json"
},
"templateSwitchPostJsonPath" : {
"mockFile": "templateSwitchSample.json",
"verbs": ["post"],
"templateSwitch": [{"key": "appID",
"switch": "$.data.appID",
"type": "jsonpath"},
{"key": "appName",
"switch": "$.data.appName",
"type": "jsonpath"},
{"key": "userName",
"switch": "$.data.user.userName",
"type": "jsonpath"},
{"key": "userAge",
"switch": "$.data.user.userAge",
"type": "jsonpath"}],
"contentType": "application/json"
},
"users": {
"mockFile": "users.json",
"verbs": [
"get"
]
},
"users/:id": {
"mockFile": "users.json",
"verbs": [
"get"
],
"switch": "id",
"jsonPathSwitchResponse": {
"jsonpath": "$[?(@.id==#id#)]",
"mockFile": "users.json",
"forceFirstObject": true
}
},
"users/role/:role": {
"mockFile": "users.json",
"verbs": [
"get"
],
"switch": "role",
"jsonPathSwitchResponse": {
"jsonpath": "$[?(@.role==\"#role#\")]",
"mockFile": "users.json",
"forceFirstObject": false
}
},
"upload": {
"verbs": ["post"],
"mockFile": "uploads/sampleFile",
"uploadDirectory": "uploads"
},
"upload-form": {
"verbs": ["get"],
"mockFile": "upload-form.html",
"contentType": "text/html"
},
"raw": {
"mockBody": "{ \"text\" : \"Good Job!\" }",
"verbs": ["all"]
},
"raw/template/:message": {
"mockBody": "{ \"text\" : \"@message\" }",
"enableTemplate" : true,
"contentType": "application/json",
"verbs": ["get"]
}
}
}