-
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
callbacks
is a map of Callback Objects.... but why?
#1141
Comments
I believe the idea of multiple distinct callback objects was introduced to support the notion of webhooks returning different "events". All of the callbacks might target the same client URL but the structure of the payload might be very different. Now that we have added support for JSON Schema e.g. callbacks:
bankAccountDeposit:
"{$request.body#/url}&eventType=deposit":
post: ...
bankAccountWithdrawal:
"{$request.body#/url}&eventType=withdrawal":
post: ...
bankAccountOverdraft:
"{$request.body#/url}&eventType=overdraft":
post: ... The question this raises for me is why not do this? callbacks:
bankAccountEvents:
"{$request.body#/url}&eventType=deposit":
post: ...
"{$request.body#/url}&eventType=withdrawal":
post: ...
"{$request.body#/url}&eventType=overdraft":
post: ... This gets a bit more unclear if the event type was not in the query string but in a header or the body and of course the key is no longer unique, which is a bigger problem. Is this better? callbacks:
bankAccountDeposit:
targetUrl: "{$request.body#/url}&eventType=deposit":
post: ...
bankAccountWithdrawal:
targetUrl: "{$request.body#/url}&eventType=withdrawal":
post: ...
bankAccountOverdraft:
targetUrl: "{$request.body#/url}&eventType=overdraft":
post: ... This does mean that if a single subscription has multiple callback URLs provided by the consumer then it would need to define distinct callback objects. Which coincidentally is what we did in the workshop example. callbacks:
heartbeat:
'$request.query.heartbeat-url':
post:
requestBody:
$ref: '#/components/requestBodies/heartbeatMessage'
responses:
'200':
description: Consumer acknowledged the callback
failed:
'$response.body#/failedUrl':
post:
requestBody:
$ref: '#/components/requestBodies/failedMessage'
responses:
'200':
description: Consumer acknowledged the callback
success:
'$response.body#/successUrl':
post:
requestBody:
$ref: '#/components/requestBodies/successMessage'
responses:
'200':
description: Consumer acknowledged the callback |
It depends on where you're looking at In the paths:
/test:
get:
## blah blah
callbacks:
foo:
$ref: '#/components/callbacks/bar and in the Then you must mean inside the That said, it could change, but I think the goal was to make references easy. If it were a callbacks:
$ref: '#/components/callbacks/foo'
# oh snap! vs. this: callbacks:
foo:
$ref: '#/components/callbacks/foo'
bar:
$ref: '#/components/callbacks/bar' Right? |
We're going leave this as-is, and see how the feature is used. Future versions may change the definition. |
The way the
callbacks
property is defined now, this is valid:This means that you can define two different Callback Objects, each one having the same expression as a key, pointing to a different POI. That doesn't seem to make sense.
Perhaps callbacks should just be a Callback Object?
The text was updated successfully, but these errors were encountered: