Skip to content

Commit

Permalink
dynamic-select: add CHANGELOG entry and docs updates for dynamic vari…
Browse files Browse the repository at this point in the history
…ant of select
  • Loading branch information
anussel5559 committed Sep 9, 2024
1 parent 6101f3d commit a8aa100
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Added

- Use `SLUMBER_CONFIG_PATH` to customize configuration (_not_ collection) file path [#370](https://github.com/LucasPickering/slumber/issues/370)
- Add a dynamic variant to `!select` chain type, allowing your collection to present a list of values driven from the output of another chain.
- [See docs for more](https://slumber.lucaspickering.me/book/api/request_collection/chain_source.html#select)

### Fixed

Expand Down
33 changes: 29 additions & 4 deletions docs/src/api/request_collection/chain_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,19 @@ password:

Prompt the user to select a defined value from a list.

| Field | Type | Description | Default |
| --------- | ------------ | -------------------------------------- | -------- |
| `message` | `Template` | Descriptive prompt for the user | Chain ID |
| `options` | `Template[]` | List of options to present to the user | Required |
| Field | Type | Description | Default |
| --------- | ---------------------------------- | -------------------------------------- | -------- |
| `message` | `Template` | Descriptive prompt for the user | Chain ID |
| `options` | [`SelectOptions`](#Select-options) | List of options to present to the user | Required |

#### Select Options

The list of options to present to the user. This can be a static list of values or a dynamic configuration to generate the list of options.

| Variant | Type | Description |
| --------- | ------------------------------------------------- | ------------------------------------------------------------ |
| `fixed` | `Template[]` | A fixed list of options |
| `dynamic` | [`DynamicSelectOptions`](#dynamic-select-options) | A dynamic configuration used to generate the list of options |

#### Examples

Expand All @@ -188,4 +197,20 @@ fruit:
- apple
- banana
- guava
dynamic_fruit:
source: !select
message: Select Fruit
options:
source: "{{chains.request_fruit}}"
selector: $.fruits[*]
```

### Dynamic Select Options

This defines a dynamic configuration used to generate the list of options in a select chain. The `source` output could be any JSON value, in which case a `selector` must be used to filter to a JSON array.
If the `source` output is already a JSON array, no selector is required.

| Field | Type | Description | Default |
| ---------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -------- |
| `source` | `Template` | The source of the data to drive the list of options. | Required |
| `selector` | [`JSONPath`](https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html) | A JSONPath expression to filter down to a JSON array. | `null` |

0 comments on commit a8aa100

Please sign in to comment.