Skip to content

Commit 6e6c4f6

Browse files
committed
Callback review and preliminary message expression syntax
1 parent 81bac40 commit 6e6c4f6

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

versions/3.0.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,15 +1555,70 @@ description: object created
15551555

15561556
#### <a name="callbackObject"></a>Callback Object
15571557

1558-
A container for possible out-of band callbacks from an operation. A callback may be returned from an operation, calling back to the path specified in the operation object.
1558+
A map of possible out-of band callbacks related to the parent operation. Each value in the map is an [operation object](#operationObject) that describes a request that may be initiated by the API provider and the responses expected. The key value used to identify callback object is an expression, that when evaluated at runtime, identifies a URL to used for the callback operation.
15591559

15601560
##### Patterned Fields
15611561
Field Pattern | Type | Description
15621562
---|:---:|---
1563-
<a name="responseName"></a>Callback name | [Callback Operation Object](#operationObject) <span>&#124;</span> [Operation Object](#operationObject) | An operation object used to define a callback payload structure
1563+
<a name="responseName"></a>Callback name | [Callback Operation Object](#operationObject) <span>&#124;</span> [Operation Object](#operationObject) | An operation object used to define a callback request and expected responses
15641564

15651565
This object can be extended with [Specification Extensions](#specificationExtensions).
15661566

1567+
##### Key Expression
1568+
1569+
The key used to identify the callback object is also an expression that can be evaluated on the runtime HTTP request/response to identify the URL to be used for the callback request. A simple example might be "$request.body.url". However, the expression syntax enables accessing the complete HTTP message and reaching into any payload that can map to an object/array/property data model.
1570+
1571+
The expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax
1572+
1573+
```
1574+
expression = target source *( "." bind-token [ index ]] )
1575+
target = ("$request." | "$response.")
1576+
source = ( header-reference | query-reference | path-reference | body-reference )
1577+
header-reference = "header." token
1578+
query-reference = "query." name
1579+
path-reference = "path." name
1580+
body-reference = "body" *( index | "." name )
1581+
index = "[" *(digit) "]"
1582+
name = *( char )
1583+
char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7)
1584+
token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6)
1585+
```
1586+
1587+
The `name` identifier is case-sensitive, whereas `token` is not.
1588+
1589+
Given the following HTTP request:
1590+
1591+
```http
1592+
POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1
1593+
Host: example.org
1594+
Content-Type: application/json
1595+
Content-Length: 123
1596+
1597+
{
1598+
"failedurl" : "http://clientdomain.com/failed"
1599+
"successurls : [
1600+
"http://clientdomain.com/fast",
1601+
"http://clientdomain.com/medium",
1602+
"http://clientdomain.com/slow"
1603+
]
1604+
}
1605+
1606+
201 Created
1607+
Location: http://example.org/subscription/1
1608+
1609+
```
1610+
1611+
Here are the examples of how the various expressions evaluate, assuming a the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`.
1612+
1613+
Expression | Value
1614+
---|:---
1615+
$request.path.eventType | myevent
1616+
$request.query.queryUrl | http://clientdomain.com/stillrunning
1617+
$request.header.content-Type | application/json
1618+
$request.body.failed | http://clientdomain.com/stillrunning
1619+
$request.body.successurls[2] | http://clientdomain.com/medium
1620+
$response.header.Location | http://example.org/subscription/1
1621+
15671622

15681623
##### Callback Object Example
15691624

@@ -1572,7 +1627,7 @@ A callback to the URL specified by the `url` parameter in the request
15721627

15731628
```yaml
15741629
myWebhook:
1575-
'$request.url':
1630+
'$request.body.url':
15761631
post:
15771632
body:
15781633
name: postResponse

0 commit comments

Comments
 (0)