Skip to content
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

Merged
merged 9 commits into from
Feb 22, 2017

Conversation

darrelmiller
Copy link
Member

No description provided.

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.
Copy link

@DavidBiesack DavidBiesack Feb 20, 2017

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"

Copy link

@DavidBiesack DavidBiesack Feb 20, 2017

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... "

Copy link
Member Author

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
---|:---:|---
Copy link

@DavidBiesack DavidBiesack Feb 20, 2017

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.

Copy link
Member Author

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>&#124;</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>&#124;</span> [Operation Object](#operationObject) | An operation object used to define a callback request and expected responses

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name="callbackName" perhaps?

Copy link
Member Author

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.

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.

Copy link
Member Author

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

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.)

Copy link
Member Author

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.

Copy link
Member Author

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

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.

Copy link
Member Author

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) "]"

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.

Copy link
Member Author

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 :-)

@darrelmiller
Copy link
Member Author

@DavidBiesack Huge thanks for the feedback. I've made most of the fixes. Updated PR coming soon.

@darrelmiller
Copy link
Member Author

darrelmiller commented Feb 20, 2017

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 $request.path.{name} $request.query.{name} and $request.header.{name} since the parameter names are only unique in a single location.

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:
e.g.

 $response.body(/id)

Another alternative syntax would be

$response.body#/id

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"
Copy link
Member

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)

Copy link
Member

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.

@whitlockjc
Copy link
Member

:shipit:

@fehguy
Copy link
Contributor

fehguy commented Feb 21, 2017

Well that's a fun read! Looks good to me, you have my 👍

Copy link
Member

@webron webron left a 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.
Copy link
Member

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).
Copy link
Member

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`.
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected!

@webron
Copy link
Member

webron commented Feb 22, 2017

:shipit: 👍

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants