Skip to content

Commit

Permalink
docs: variable types
Browse files Browse the repository at this point in the history
  • Loading branch information
gurleensethi committed Mar 29, 2023
1 parent f0525c6 commit 0fcb38d
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,44 @@ You can provide as many variable files as you want.
$ yurl -var-file local.vars -var-file staging.vars Login
```

All the variables are added to the **variable set**.
All the variables are added to the **variable set**.

## Variable Types

You can define types on variables when the value is prompted from the user.

Use the pattern: `{{ <var name>:<type> }}` to enforce a type.

```yaml title="http.requests"
requests:
GetTodoById:
method: GET
path: /todos/{{ id:int }} # (1)!
headers:
Accept: application/json
```

1. Types are defined using `<var name>:<type>` pattern.

```bash linenums="0"
$ yurl GetTodoById
Enter `id` (int): 10
```

In the above example, type `int` is defined for the variable `id`. When the prompt is presented to the user for value the required type is also displayed.

If the entered value is not valid, `yurl` errors immediately.

```bash linenums="0"
$ yurl GetTodoById
Enter `id` (int): not int

input for `id` must be of type int
```

Currently the following types are supported:

- `string`
- `int`
- `float`
- `bool`

0 comments on commit 0fcb38d

Please sign in to comment.