Manifest
Stub manifest documentation
# data/users.yaml
version: v1.1 # 1
type: Rule # 2
rules: # 3
- when: path.userId == 2 # 3.1
request: # 3.2
path: /users/{userId} # 3.2.1
method: GET # 3.2.2
relative: true # 3.2.3
response: # 3.3
status: 200 # 3.3.1
headers: # 3.3.2
content-type: application/json
body: # 3.3.3
id: ${path.userId}
name: ${tables.name}
file: myfile.txt # 3.3.4
delay: 333 # 3.3.5
tables: # 3.3.6
- name: name
key: path.userId
values:
1: Foo
callback: println('Hello') # 3.4
Description:
version
- version of manifesttype
- for type of object declarationrules
- block for rules groupingwhen
- conditional statementrequest
- request setuppath
- endpoint pathmethod
- endpoint methodrelative
- relative to current folder path(calculates from stubs folder)
response
- this block was added to change a declaration solution related to foldersstatus
- http status of responseheaders
- response headersbody
- response bodyfile
- response body from the file contentsdelay
- responsible for network latency simulationtables
- source of data for templating (For more info, please follow next link)
callback
- post action hook
More info about each field could be found in next.
Relative request declaration
relative
parameter allows you to declare endpoints relative to the content root.
For example: If you create a file in the following user/groups
folder, set relative
to true
and create the following manifest:
# data/user/groups/report.yml
version: v1.1
type: Stub
rules:
- request:
path: /report/1
method: GET
relative: true
Next endpoint will be generated user/groups/report/1
.
Default values of Stub
version
v1.3
type
Stub
request.path
/
request.method
GET
request.relative
true
Different styles of manifest
The following declaration styles are allowed
First
# manifest #1
version: v1.3
type: Stub
rules:
- request:
path: /users
method: GET
relative: true
response:
headers:
content-type: application/json
body:
- id: 1
name: Foo
- id: 2
name: Bar
Second
# manifest #2
rules:
- request:
path: /users
response:
headers:
content-type: application/json
body:
- id: 1
name: Foo
- id: 2
name: Bar
Third
# manifest #3
request:
path: /users
response:
headers:
content-type: application/json
body:
- id: 1
name: Foo
- id: 2
name: Bar
Fourth
# manifest #4
response:
headers:
content-type: application/json
body:
- id: 1
name: Foo
- id: 2
name: Bar
More info
RecipesTemplateLast updated