-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Callback review and preliminary message expression syntax #891
Conversation
versions/3.0.md
Outdated
@@ -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. |
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"
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.
versions/3.0.md
Outdated
@@ -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 comment
The 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 comment
The 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.
versions/3.0.md
Outdated
|
||
##### Patterned Fields | ||
Field Pattern | Type | Description | ||
---|:---:|--- | ||
<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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
versions/3.0.md
Outdated
|
||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks!
versions/3.0.md
Outdated
|
||
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. | ||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider using JSON Pointer or JSONPath for the body-reference
expressions? In particular, when extracting elements from arrays, it is often necessary to pass in predicates/filters to match a specific array elements. (I'm extrapolating based on from experience with UnRAVL which also allows extracting data from response bodies.)
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.
I had not considered using those for just the body-reference
. I had ruled out using them for the complete expression, but using it for just the body-reference is quite an cool idea. I'd like to use JSON Pointer because we already need that in tooling to support $refs.
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 comment
The 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.
versions/3.0.md
Outdated
$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 comment
The 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
would return the second successurl if it exists, or the location header.
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.
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.
versions/3.0.md
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
If we move to JSONPointer, I can punt on this :-)
@DavidBiesack Huge thanks for the feedback. I've made most of the fixes. Updated PR coming soon. |
This latest update has a number of changes to the variable expressions used for both callbacks and links. It was necessary to add syntax to access parameters using Also, instead of creating a new syntax for reaching into request and response bodies, this proposal suggests using a JSON Pointer for accessing the body instead:
Another alternative syntax would be
But I'm tending to prefer the function style over the fragment |
versions/3.0.md
Outdated
Content-Length: 123 | ||
|
||
{ | ||
"failedurl" : "http://clientdomain.com/failed" |
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.
Suggest failedUrl
and successUrls
(camel)
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.
I like the $response.body#/id
variant.
Well that's a fun read! Looks good to me, you have my 👍 |
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.
Added some cosmetic changes.
versions/3.0.md
Outdated
|
||
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 expected responses. |
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.
We can fix it later, but should be Operation Object
versions/3.0.md
Outdated
The key used to identify the callback object is a variable expression that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. | ||
A simple example might be `$request.body#/url`. | ||
However, using [variable substition](#variableSubstition) syntax the complete HTTP message can be accessed. | ||
This includes accessing any part of a body that can be accessed using a JSONPointer [RFC6901](https://tools.ietf.org/html/rfc6901). |
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.
JSON Pointer
description | string | a description of the link, supports [CommonMark syntax](http://spec.commonmark.org/). | ||
href | `string` | a relative or absolute URL to a linked resource. This field is mutually exclusive with the `operationId` field. | ||
operationId | `string` | the name of an _existing_, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive with the `href` field. Relative `href` values _may_ be used to locate an existing Operation Object in the OAS. | ||
parameters | [Link Parameters Object](#linkParameters) | an Object representing parameters to pass to an operation as specified with `operationId` or identified via `href`. |
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.
Parameters Object
instead of Link Parameters Object
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.
I stand corrected!
👍 I was going to say something about headers being case insensitive but you got it! Does it make sense to support cookies too in variable substitution? (#probablynot #pleasedontkillme) |
Callback review and preliminary message expression syntax
No description provided.