-
Notifications
You must be signed in to change notification settings - Fork 6
Complete Schema
Do Trong Long edited this page Feb 13, 2020
·
5 revisions
Below is complete schema for faker
{
"plugins": [
{
"name": "delay",
"args": {"duration": 500}
}
],
"request": {
"scheme": "http",
"host": "localhost",
"port": 3030,
"method": "get",
"path": "/some-urls",
"headers": {
"content-type": "application/json"
}
},
"response": {
"statusCode": 200,
"headers": {
"content-type": "application/json; charset=utf-8",
"trace-id": "some-trace-id"
},
"body": [
{
"id": 1,
"name": "John"
},
{
"id": 2,
"name": "Marry"
}
]
}
}
-
plugins
:-
delay
: (optional) delays response for a number of milliseconds (good to test behaviours in slow connection)
-
-
request
: configures request's specification-
scheme
: (optional) matches request's url scheme, such ashttps
,http
,ftp
-
host
: (optional) matches the host of url -
port
: (optional) an integer represents for port of request -
path
: request's path, includes request's query -
method
: request's method, e.g,GET
,POST
, this field is case-insensitive -
headers
: (optional) request must contain all of headers specified
-
-
response
: configure response to be returned-
code
: (optional) response's code, for example, 200, 500 -
headers
: (optional) response's headers -
body
: response's body
-
Last but not least, if faker
could not find appropriate schema, a 404
response will be returned.