# Manifest

```yaml
# 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 manifest
* `type` - for type of object declaration
* `rules` - block for rules grouping
* `when` - conditional statement
* `request` - request setup
  * `path` - endpoint path
  * `method` - endpoint method
  * `relative` - relative to current folder path(calculates from stubs folder)
* `response` - this block was added to change a declaration solution related to folders

  * `status` - http status of response
  * `headers` - response headers
  * `body` - response body
  * `file` - response body from the file contents
  * `delay` - responsible for network latency simulation
  * `tables` - source of data for templating (*For more info, please follow next* [*link*](https://httpstubhq.gitbook.io/httpstub/stubs/tables))

  `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:

```yaml
# 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`.&#x20;

### Default values of Stub

| Name             | Default value |
| ---------------- | ------------- |
| version          | v1.3          |
| type             | Stub          |
| request.path     | /             |
| request.method   | GET           |
| request.relative | true          |

### Different styles of manifest

The following declaration styles are allowed

#### First

```yaml
# 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

```yaml
# manifest #2
rules: 
  - request:          
      path: /users    
    response:
      headers:
        content-type: application/json
      body:
        - id: 1
          name: Foo
        - id: 2
          name: Bar
```

#### Third

```yaml
# manifest #3
request:          
  path: /users    
response:
  headers:
    content-type: application/json
  body:
    - id: 1
      name: Foo
    - id: 2
      name: Bar
```

#### Fourth

```yaml
# manifest #4
response:
  headers:
    content-type: application/json
  body:
    - id: 1
      name: Foo
    - id: 2
      name: Bar
```

## More info

{% content-ref url="recipes" %}
[recipes](https://httpstubhq.gitbook.io/httpstub/stubs/recipes)
{% endcontent-ref %}

{% content-ref url="template" %}
[template](https://httpstubhq.gitbook.io/httpstub/stubs/template)
{% endcontent-ref %}
