Skip to content

Commit

Permalink
feat: Add support for XPath and versions of XPath and JSON Path for C…
Browse files Browse the repository at this point in the history
…riterion expressions
  • Loading branch information
frankkilcommins committed Apr 9, 2024
1 parent 5f25cc1 commit 97ce294
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions versions/1.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ stepId: joinWaitingListStep
criteria:
# assertions to determine if this success action should be executed
- context: $response.body
condition: $.Pets.length() > 0
condition: $[?count(@.pets) > 0]
type: JSONPath
```

Expand Down Expand Up @@ -704,7 +704,7 @@ Field Name | Type | Description
---|:---:|---
<a name="criterionContext"></a>context | `{expression}` | A [runtime expression](#runtime-expressions) used to set the context for the condition to be applied on. If `type` is specified, then the `context` MUST be provided (e.g. `$response.body` would set the context that a JSONPath query expression could be applied to).
<a name="criterionCondition"></a>condition | `string` | **REQUIRED**. The condition to apply. Conditions can be simple (e.g. `$statusCode == 200` which applies a operator on a value obtained from a runtime expression), or a regex, or a JSONPath expression. For regex and [JSONPath](https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base/21/), the `type` and `context` MUST be specified.
<a name="criterionType"></a>type | `string` | The type of condition to be applied. If specified, the options allowed are `simple`, `regex` or `JSONPath`. If omitted, then the condition is assumed to be `simple`, which at most combines literals, operators and [Runtime Expressions](#runtime-expressions).
<a name="criterionType"></a>type | `string` \| [Criterion Expression Type Object](#criterion-expression-type-object) | The type of condition to be applied. If specified, the options allowed are `simple`, `regex`, `jsonpath` or `xpath`. If omitted, then the condition is assumed to be `simple`, which at most combines literals, operators and [Runtime Expressions](#runtime-expressions). If `jsonpath`, then the expression MUST conform to [JSON Path](https://www.rfc-editor.org/rfc/rfc9535.html). If `xpath` the expression MUST conform to [XML Path Language 3.1](https://www.w3.org/TR/xpath-31/#d2e24229). Should other variants of JSON Path or XPath be required, then a [Criterion Expression Type Object](#criterion-expression-type-object) MUST be specified.


This object MAY be extended with [Specification Extensions](#specificationExtensions).
Expand All @@ -727,8 +727,38 @@ This object MAY be extended with [Specification Extensions](#specificationExtens
**JSONPath Condition Example**
```yaml
- context: $response.body
condition: $[?length(@.pets) > 0]
type: JSONPath
condition: $[?count(@.pets) > 0]
type: jsonpath
```

#### Criterion Expression Type Object

An object used to describe the type and version of an expression used within a [Criterion Object](#criterion-object). If this object is not defined, then the following defaults apply:
- JSON Path as described by [RFC 9535](https://www.rfc-editor.org/rfc/rfc9535.html)
- XPath as described by [XML Path Language 3.1](https://www.w3.org/TR/xpath-31)

Defining this object gives the ability to utilize tooling compatible with older versions of either JSON Path or XPath.

##### Fixed Fields
Field Name | Type | Description
---|:---:|---
<a name="criterionExpressionType"></a>type | `string` | **REQUIRED**. The type of condition to be applied. The options allowed are `jsonpath` or `xpath`.
<a name="criterionExpressionVersion"></a>version | `string` | **REQUIRED**. A short hand string representing the version of the expression type being used. The allowed values for JSON Path are `draft-goessner-dispatch-jsonpath-00`. The allowed values for XPath are `xpath-30`, `xpath-20`, or `xpath-10`.

This object MAY be extended with [Specification Extensions](#specificationExtensions).

##### Criterion Expression Type Example

**JSON Path Example**
```yaml
type: jsonpath
version: draft-goessner-dispatch-jsonpath-00
```

**XPath Example**
```yaml
type: xpath
version: xpath-30
```

#### Request Body Object
Expand Down

0 comments on commit 97ce294

Please sign in to comment.