Skip to content

Commit

Permalink
Update examples based on Criterion Object addition
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkilcommins committed Oct 14, 2023
1 parent 6088579 commit 8e25bd5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
6 changes: 3 additions & 3 deletions examples/1.0.0/FAPI-PAR.workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ workflows:
value: $inputs.PARrequestBody
successCriteria:
# assertions to determine step was successful
- $statusCode == 200
- condition: $statusCode == 200
outputs:
request_uri: $response.body.request_uri

Expand All @@ -131,7 +131,7 @@ workflows:
value: $inputs.client_id
successCriteria:
# assertions to determine step was successful
- $statusCode == 302
- condition: $statusCode == 302
outputs:
code: $response.body.code # Not really, this is a query parameter (need a way to represent out-of-band props)

Expand Down Expand Up @@ -166,7 +166,7 @@ workflows:
value: $inputs.code_verifier
successCriteria:
# assertions to determine step was successful
- $statusCode == 200
- condition: $statusCode == 200
outputs:
tokenResponse: $response.body

Expand Down
4 changes: 2 additions & 2 deletions examples/1.0.0/LoginAndRetrievePets.workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ workflows:
value: $inputs.password
successCriteria:
# assertions to determine step was successful
- $statusCode == 200
- condition: $statusCode == 200
outputs:
# outputs from this step
tokenExpires: $response.header.X-Expires-After
Expand All @@ -53,7 +53,7 @@ workflows:
in: header
value: $steps.loginUser.outputs.sessionToken
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
# outputs from this step
availablePets: $response.body
Expand Down
24 changes: 16 additions & 8 deletions examples/1.0.0/oauth.workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ workflows:
grant_type: refresh_token
refresh_token: $steps.do-the-auth-flow.outputs.my_refresh_token
successCriteria:
- $statusCode == 200
- $response.body.access_token != null
- condition: $statusCode == 200
- context: $response.body
condition: $.access_token != null
type: JSONPath
outputs:
access_token: $response.body.access_token
refresh_token: $response.body.refresh_token
Expand Down Expand Up @@ -105,8 +107,10 @@ workflows:
value: 'client_credentials'

successCriteria:
- $statusCode == 200
- $response.body.access_token != null
- condition: $statusCode == 200
- context: $response.body
condition: $.access_token != null
type: JSONPath
outputs:
access_token: $response.body.access_token

Expand Down Expand Up @@ -153,8 +157,10 @@ workflows:
in: query
value: '12345'
successCriteria:
- $statusCode == 200
- $response.body.access_token != null
- condition: $statusCode == 200
- context: $response.body
condition: $.access_token != null
type: JSONPath
outputs:
code: $response.body.code # Not really, this is a query parameter

Expand Down Expand Up @@ -185,8 +191,10 @@ workflows:
value: $steps.browser-authorize.outputs.code

successCriteria:
- $statusCode == 200
- $response.body.access_token != null
- condition: $statusCode == 200
- context: $response.body
condition: $.access_token != null
type: JSONPath
outputs:
access_token: $response.body.access_token
refresh_token: $response.body.refresh_token
Expand Down
12 changes: 6 additions & 6 deletions examples/1.0.0/pet-coupons.workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ workflows:
in: query
value: $inputs.my_pet_tags
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_pet_id: $outputs[0].id
# there is some implied selection here - findPetsByTags responds with a list of pets,
Expand All @@ -40,7 +40,7 @@ workflows:
in: path
value: $steps.find-pet.outputs.my_pet_id
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_coupon_code: $response.body.couponCode
- stepId: place-order
Expand All @@ -53,7 +53,7 @@ workflows:
in: body
value: $steps.find-coupons.outputs.my_coupon_code
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_order_id: $response.body.id
- workflowId: buy-available-pet
Expand All @@ -75,7 +75,7 @@ workflows:
- $ref: '#/components/parameters/pageSize'
value: 10
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_pet_id: $outputs[0].id
- stepId: place-order
Expand All @@ -85,7 +85,7 @@ workflows:
in: body
value: $steps.find-pet.outputs.my_pet_id
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_order_id: $response.body.id
- workflowId: place-order
Expand Down Expand Up @@ -130,7 +130,7 @@ workflows:
target: $request.body#/complete
value: false
successCriteria:
- $statusCode == 200
- condition: $statusCode == 200
outputs:
my_order_id: $response.body.id
components:
Expand Down
6 changes: 3 additions & 3 deletions versions/1.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ This object cannot be extended with additional properties and any properties add
An object used to specify the context, conditions, and condition types that can be used to prove or satisfy assertions specified in Step Object `successCriteria`, Success Action Object `criteria`, and Failure Action Object `criteria`.

There are three flavors of conditions supported:
- simple - where basic literals, operators, and loose comparisons are used in combination with [Runtime Expressions](#runtime-expressions)
- simple - where basic literals, operators, and loose comparisons are used in combination with [Runtime Expressions](#runtime-expressions).
- regex - where a regex pattern is applied on the supplied context. The context is defined by a [Runtime Expression](#runtime-expressions).
- JSONPath - where a JSONPath expression is applied. The root node context is defined by a [Runtime Expression](#runtime-expressions).

Expand Down Expand Up @@ -659,7 +659,7 @@ String comparisons `SHOULD` be case insensitive.
##### Fixed Fields
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 could be applied to).
<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 `regex` or `JSONPath`. If omitted, then the condition is assumed to be simple, which at most combines literals, operators and [Runtime Expressions](#runtime-expressions).

Expand All @@ -684,7 +684,7 @@ This object _MAY_ be extended with [Specification Extensions](#specificationExte
**JSONPath Condition Example**
```yaml
- context: $response.body
condition: $.pets.length() > 0
condition: $[?length(@.pets) > 0]
type: JSONPath
```

Expand Down

0 comments on commit 8e25bd5

Please sign in to comment.