-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Callback review and preliminary message expression syntax #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6e6c4f6
fcc6c66
4197f43
4068d00
bc9da31
b268c06
17fdf10
9e6f586
d4e2cfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1555,15 +1555,70 @@ description: object created | |
|
||
#### <a name="callbackObject"></a>Callback Object | ||
|
||
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. | ||
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. | ||
|
||
##### Patterned Fields | ||
Field Pattern | Type | Description | ||
---|:---:|--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe CommonMark does not support tables with this notation; one must use HTML <table> elements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :-) I realize this might sound a little hypocritical but we are suggesting CommonMark in OpenAPI definitions, but we are still using GFM in the spec. |
||
<a name="responseName"></a>Callback name | [Callback Operation Object](#operationObject) <span>|</span> [Operation Object](#operationObject) | An operation object used to define a callback payload structure | ||
<a name="responseName"></a>Callback name | [Callback Operation Object](#operationObject) <span>|</span> [Operation Object](#operationObject) | An operation object used to define a callback request and expected responses | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name="callbackName" perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
||
This object can be extended with [Specification Extensions](#specificationExtensions). | ||
|
||
##### Key Expression | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "evaluated in the context of a runtime HTTP request/response" (It's not clear what "evaluated on the runtime HTTP request/response object means" since those are not executable, but they do provide a context for expression evaluation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Thanks! |
||
|
||
The expression is defined by the following [ABNF](https://tools.ietf.org/html/rfc5234) syntax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you consider using JSON Pointer or JSONPath for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had not considered using those for just the I have a fairly significant update to this PR because I found it contradicted some of the docs in Links which I am also reviewing. I'll post an update soon and I'll see if it is easy to incorporate JSONPointer. Nice thing about that is approach is in the future we could open the door to using other fragment syntaxes for other media types where JSONPointer is not appropriate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about the predicates/filters, I do see the value but it adds quite a bit of work for tooling. I'm not going to include anything for the moment, but I'll bring it up with the TDC tomorrow. |
||
|
||
``` | ||
expression = target source *( "." bind-token [ index ]] ) | ||
target = ("$request." | "$response.") | ||
source = ( header-reference | query-reference | path-reference | body-reference ) | ||
header-reference = "header." token | ||
query-reference = "query." name | ||
path-reference = "path." name | ||
body-reference = "body" *( index | "." name ) | ||
index = "[" *(digit) "]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. document is indexing is zero-based (I assume, recommend) or 1-based. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we move to JSONPointer, I can punt on this :-) |
||
name = *( char ) | ||
char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7) | ||
token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6) | ||
``` | ||
|
||
The `name` identifier is case-sensitive, whereas `token` is not. | ||
|
||
Given the following HTTP request: | ||
|
||
```http | ||
POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1 | ||
Host: example.org | ||
Content-Type: application/json | ||
Content-Length: 123 | ||
|
||
{ | ||
"failedurl" : "http://clientdomain.com/failed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the |
||
"successurls : [ | ||
"http://clientdomain.com/fast", | ||
"http://clientdomain.com/medium", | ||
"http://clientdomain.com/slow" | ||
] | ||
} | ||
|
||
201 Created | ||
Location: http://example.org/subscription/1 | ||
|
||
``` | ||
|
||
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`. | ||
|
||
Expression | Value | ||
---|:--- | ||
$request.path.eventType | myevent | ||
$request.query.queryUrl | http://clientdomain.com/stillrunning | ||
$request.header.content-Type | application/json | ||
$request.body.failed | http://clientdomain.com/stillrunning | ||
$request.body.successurls[2] | http://clientdomain.com/medium | ||
$response.header.Location | http://example.org/subscription/1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This expression notation may need some mechanism to provide a default value if the item is not found, i.e. $request.body.successurls[2] | $response.header.Location There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Links section, the suggestion is that if the item is not found, then the value is null. I'm not exactly sure what we do if the reference points to something that is not a primitive. |
||
|
||
|
||
##### Callback Object Example | ||
|
||
|
@@ -1572,7 +1627,7 @@ A callback to the URL specified by the `url` parameter in the request | |
|
||
```yaml | ||
myWebhook: | ||
'$request.url': | ||
'$request.body.url': | ||
post: | ||
body: | ||
name: postResponse | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add article "the" : "used to identify the callback object"
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested: "is an expression, evaluated at runtime, that identifies... "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.