Skip to content

Instantly share code, notes, and snippets.

@255kb
Created September 24, 2020 19:01
Show Gist options
  • Save 255kb/3816011e54ebef2de2d8e0887675e926 to your computer and use it in GitHub Desktop.
Save 255kb/3816011e54ebef2de2d8e0887675e926 to your computer and use it in GitHub Desktop.
Web Zürich Mockoon mock API demo
{
"source": "mockoon:1.10.0",
"data": [
{
"type": "environment",
"item": {
"uuid": "",
"lastMigration": 12,
"name": "Web Zürich demo",
"endpointPrefix": "",
"latency": 0,
"port": 3000,
"routes": [
{
"uuid": "",
"documentation": "Generate random body (JSON, text, CSV, etc) with templating",
"method": "get",
"endpoint": "content/json",
"responses": [
{
"uuid": "",
"body": "{\n \"Templating example\": \"For more information about templating, click the blue 'i' above this editor\",\n \"users\": [\n {{# repeat (queryParam 'total' '10') }}\n {\n \"userId\": \"{{ faker 'random.number' min=10000 max=100000 }}\",\n \"firstname\": \"{{ faker 'name.firstName' }}\",\n \"lastname\": \"{{ faker 'name.lastName' }}\",\n \"friends\": [\n {{# repeat (faker 'random.number' 5) }}\n {\n \"id\": \"{{ faker 'random.uuid' }}\"\n }\n {{/ repeat }}\n ]\n },\n {{/ repeat }}\n ],\n \"total\": \"{{queryParam 'total' '10'}}\"\n}",
"latency": 0,
"statusCode": 200,
"label": "Creates 10 random users, or the amount specified in the 'total' query param",
"headers": [
{
"key": "",
"value": ""
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
},
{
"uuid": "",
"documentation": "Generate random body (JSON, text, CSV, etc) with templating",
"method": "get",
"endpoint": "content/csv",
"responses": [
{
"uuid": "",
"body": "city,zipcode,state,latitude,longitude\n{{# repeat (queryParam 'total' '10') }}\n{{faker 'address.city'}},{{faker 'address.zipCode'}},{{faker 'address.state'}},{{faker 'address.latitude'}},{{faker 'address.longitude'}}\n{{/ repeat}}",
"latency": 0,
"statusCode": 200,
"label": "Creates 10 random users, or the amount specified in the 'total' query param",
"headers": [
{
"key": "Content-Type",
"value": "text/csv"
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
},
{
"uuid": "",
"documentation": "Serve a file dynamically depending on the path param 'pageName'.",
"method": "get",
"endpoint": "file/:pageName",
"responses": [
{
"uuid": "",
"body": "",
"latency": 0,
"statusCode": 200,
"label": "Templating is also supported in file path",
"headers": [
{
"key": "Content-Type",
"value": "text/html"
}
],
"filePath": "./page{{urlParam 'pageName'}}.html",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
},
{
"uuid": "",
"documentation": "Use multiple responses with rules",
"method": "post",
"endpoint": "rules/:param1",
"responses": [
{
"uuid": "",
"body": "{\n \"Rules example\": \"Default response. Served if route param 'param1' is not present.\"\n}",
"latency": 0,
"statusCode": 200,
"label": "Default response",
"headers": [
{
"key": "",
"value": ""
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
},
{
"uuid": "",
"body": "{\n \"Rules example\": \"Content XYZ. Served if route param 'param1' equals 'xyz'. (See in 'Rules' tab)\"\n}",
"latency": 0,
"statusCode": 200,
"label": "Content XYZ",
"headers": [
{
"key": "",
"value": ""
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [
{
"target": "params",
"modifier": "param1",
"value": "xyz",
"isRegex": false
}
],
"rulesOperator": "OR",
"disableTemplating": false
},
{
"uuid": "",
"body": "{\n \"Rules example\": \"Content not found. Served if route param 'param1' is not equal to 'xyz'. (See in 'Rules' tab)\"\n}\n",
"latency": 0,
"statusCode": 404,
"label": "Content not found",
"headers": [
{
"key": "",
"value": ""
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [
{
"target": "params",
"modifier": "param1",
"value": "^(?!.*xyz).*$",
"isRegex": true
}
],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
},
{
"uuid": "",
"documentation": "Path supports various patterns",
"method": "put",
"endpoint": "path/with/pattern(s)?/*",
"responses": [
{
"uuid": "",
"body": "The current path will match the following routes: \nhttp://localhost:3000/path/with/pattern/\nhttp://localhost:3000/path/with/patterns/\nhttp://localhost:3000/path/with/patterns/anything-else\n\nLearn more about Mockoon's routing: https://mockoon.com/docs/latest/routing",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
}
],
"proxyMode": false,
"proxyHost": "",
"https": false,
"cors": true,
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"proxyReqHeaders": [
{
"key": "",
"value": ""
}
],
"proxyResHeaders": [
{
"key": "",
"value": ""
}
]
}
},
{
"type": "environment",
"item": {
"uuid": "",
"lastMigration": 12,
"name": "Proxy",
"endpointPrefix": "",
"latency": 0,
"port": 3001,
"routes": [
{
"uuid": "",
"documentation": "",
"method": "get",
"endpoint": "people/1000",
"responses": [
{
"uuid": "",
"body": "{\r\n \"name\": \"Guillaume Monnet\",\r\n \"height\": \"178\",\r\n \"mass\": \"80\",\r\n \"hair_color\": \"brown\",\r\n \"skin_color\": \"green\",\r\n \"eye_color\": \"brown\",\r\n \"birth_year\": \"1984\",\r\n \"gender\": \"male\",\r\n \"homeworld\": \"http://swapi.dev/api/planets/41/\",\r\n \"films\": [\r\n \"http://swapi.dev/api/films/4/\"\r\n ],\r\n \"species\": [\r\n \"http://swapi.dev/api/species/19/\"\r\n ],\r\n \"vehicles\": [],\r\n \"starships\": [],\r\n \"created\": \"2014-12-20T10:08:33.777000Z\",\r\n \"edited\": \"2014-12-20T21:17:50.417000Z\",\r\n \"url\": \"http://swapi.dev/api/people/1000/\"\r\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [
{
"key": "",
"value": ""
}
],
"filePath": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false
}
],
"enabled": true
}
],
"proxyMode": true,
"proxyHost": "https://swapi.dev/api/",
"https": false,
"cors": true,
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"proxyReqHeaders": [
{
"key": "",
"value": ""
}
],
"proxyResHeaders": [
{
"key": "",
"value": ""
}
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment