apimocker
Version:
Simple HTTP server that returns mock service API responses to your front end.
177 lines (176 loc) • 4.67 kB
JSON
{
"note": "used for functional tests.",
"port": "7879",
"latency": 0,
"allowedDomains": ["abc"],
"allowedHeaders": ["Content-Type", "my-custom-header"],
"corsCredentials": "true",
"proxyURL": "http://localhost:7881",
"webServices": {
"first": {
"mockFile": "king.json",
"contentType": "foobar",
"verbs": ["get"],
"alternatePaths": ["1st"]
},
"second": {
"verbs": ["delete"],
"httpStatus": 204
},
"royals": {
"verbs": ["get", "post"],
"responses": {
"get": {
"mockFile": "ace.json"
},
"post": {
"mockFile": "king.json"
}
}
},
"protected": {
"mockFile": "king.json",
"httpStatus": 403,
"verbs": ["put"]
},
"nested/ace": {
"mockFile": "ace.json",
"verbs": ["post", "get"],
"switch": "customerId"
},
"var/:id": {
"mockFile": "xml/queen.xml",
"contentType": "application/xml",
"verbs": ["all"]
},
"login": {
"mockFile": "king.json",
"verbs": ["post"],
"switch": ["userId", "password"],
"responses": {
"post": { "httpStatus": 401 }
},
"switchResponses": {
"userIduser1passwordgood": { "httpStatus": 200 }
}
},
"verify": {
"verbs": ["post"],
"switch": ["customerId"],
"switchResponses": {
"customerId1234": { "mockFile": "ace.json" }
}
},
"firstheaders": {
"mockFile": "king.json",
"contentType": "foobar",
"headers": {
"x-requested-by": "4c2df03a17a803c063f21aa86a36f6f55bdde1f85b89e49ee1b383f281d18c09c2ba30654090df3531cd2318e3c",
"dummyheader": "dummyvalue"
},
"verbs": ["get"]
},
"noMockFile": {
"verbs": ["get"]
},
"missingMockFile": {
"verbs": ["get"],
"mockFile": "missing",
"httpStatus": 203
},
"template/:name/:number": {
"mockFile": "templateSample.json",
"enableTemplate": true,
"contentType": "application/json",
"verbs": ["get"]
},
"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"],
"switch": "name",
"switchResponses": {
"nameking": { "mockFile": "king.json" }
},
"mockFile": "json",
"uploadDirectory": "uploads"
},
"upload/many": {
"verbs": ["post"],
"mockFile": "sorry.json",
"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"]
},
"body/filter": {
"verbs": ["post"],
"bodies": {
"post": [
"{ \"text\": \"Raw body filter test\" }",
{ "sha1": "46607ed90dbc35ffa40bf49db6e341e92487f2bc" }
]
},
"mockFile": "king.json"
}
}
}