You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue proposes a mechanism to allow different logical events that occur on a single WebHooks callback API to be discriminated.
Relationship to other issues
This item is one of three split out from #716 as agreed at the OAI TDC on June 17th 2016.
The three items are;
WebHook Event Subscription #735 , which covers webhook event subscription, but which is restricted to the case of modelling a single logical event stream for each physical callback API registered
This Issue extends #735 to allow discrimination between different logical event streams on the same physical callback URL. The rest of this document assumed that #735 has been read.
Proposed Syntax Updates
eventDiscriminator
This element extends the definition of x-event-streams to allow multiple logical event streams on the same physical callback URL. It extends the definition of 'parameterwithinx-event-streams` to add this element. It is only required where the 'discriminator' is contained within a header element. If the callback response body can be modelled via the existing swagger schema discriminators, then this can be used instead.
eventDiscriminator:
Parameter:parameterName
This introduced to cope with cases where the webhooks callback URL can receive more than one type of event and the event type is conveyed in the header or query perameters. In these cases, the polymorphic Swagger discriminator cannot be used. The Parameter field specifies which parameter is used to discriminate between different events that may occur.
If eventDiscriminator is present, then the parameter named has a value equal to the event-id when that event occurs
If eventDiscriminator is absent, then event types are discriminated using the Swagger discriminator, as specified for the schema of the body parameter
Discriminator in a header: Swagger YAML snippet
We have chosen to illustrate example using github because it has a subcription API.
Please refer to the Github documentation on 'create a hook'
for further information on the API definition provided by Github for webhooks.
Please note that all elements beginning with x-github or x-hub are part of the Github API
specification, and do not form part of this proposal.
Finally, the Swagger below is not comprehensive - for example, not all objects are fully modeled.
paths:
/repos/owner/repo/hooks:
post:
operationId: 'CreateHook'summary: Create a webhook in GITHUBdescription: | Call this API to create a new WebHook in Githubparameters:
- name: subscriptionin: bodydescription: Details to subscribe for a callback on a given set of eventsrequired: trueschema:
$ref: '#/definitions/Subscription'tags:
- Webhookresponses:
'202':
description: Details of the subscription created to the webhookschema:
$ref: '#/definitions/SubscriptionResponse'x-async-responses:
- eventId: commentStreamdescription: Comment event streameventDiscriminator:
parameter: X-GitHub-Eventparameters:
- name: commentin: bodyrequired: trueschema:
$ref: '#/definitions/comment'
- name: X-GitHub-Eventin: headertype: string
- name: X-GitHub-Deliveryin: headertype: string
- name: X-Hub-Signaturein: headertype: string
- event-id: deploymentdescription: deployment event streameventDiscriminator:
parameter: X-GitHub-Eventparameters:
- name: deploymentin: bodyrequired: trueschema:
$ref: '#/definitions/deployment'
- name: X-GitHub-Eventin: headertype: string
- name: X-GitHub-Deliveryin: headertype: string
- name: X-Hub-Signaturein: headertype: string
Discriminator in the message Body
In this example, the eventDiscriminator is absent, and event discrimination defaults to exploiting the discriminator defined in the schema for the body parameter.
x-event-streams:
- event-id: Dogdescription: animal event streamparameters:
- name: animalin: bodyrequired: trueschema:
$ref: '#/definitions/Dog'
- event-id: Catdescription: animal event streamparameters:
- name: animalin: bodyrequired: trueschema:
$ref: '#/definitions/Cat'definitions:
Pet:
type: objectdiscriminator: petTypeproperties:
name:
type: stringpetType:
type: stringrequired:
- name
- petTypeCat:
description: A representation of a catallOf:
- $ref: '#/definitions/Pet'
- type: objectproperties:
huntingSkill:
type: stringdescription: The measured skill for huntingdefault: lazyenum:
- clueless
- lazy
- adventurous
- aggressiverequired:
- huntingSkillDog:
description: A representation of a dogallOf:
- $ref: '#/definitions/Pet'
- type: objectproperties:
packSize:
type: integerformat: int32description: the size of the pack the dog is fromdefault: 0minimum: 0required:
- packSize
The text was updated successfully, but these errors were encountered:
Summary
This issue proposes a mechanism to allow different logical events that occur on a single WebHooks callback API to be discriminated.
Relationship to other issues
This item is one of three split out from #716 as agreed at the OAI TDC on June 17th 2016.
The three items are;
Objective of the proposal
This Issue extends #735 to allow discrimination between different logical event streams on the same physical callback URL. The rest of this document assumed that #735 has been read.
Proposed Syntax Updates
eventDiscriminator
This element extends the definition of
x-event-streams
to allow multiple logical event streams on the same physicalcallback URL
. It extends the definition of 'parameterwithin
x-event-streams` to add this element. It is only required where the 'discriminator' is contained within a header element. If the callback response body can be modelled via the existing swagger schema discriminators, then this can be used instead.eventDiscriminator:
Parameter:
parameterName
discriminator
cannot be used. TheParameter
field specifies which parameter is used to discriminate between different events that may occur.eventDiscriminator
is present, then the parameter named has a value equal to theevent-id
when that event occurseventDiscriminator
is absent, then event types are discriminated using the Swagger discriminator, as specified for the schema of the body parameterDiscriminator in a header: Swagger YAML snippet
We have chosen to illustrate example using github because it has a subcription API.
Please refer to the Github documentation on 'create a hook'
for further information on the API definition provided by Github for webhooks.
Please note that all elements beginning with
x-github
orx-hub
are part of the Github APIspecification, and do not form part of this proposal.
Finally, the Swagger below is not comprehensive - for example, not all objects are fully modeled.
Discriminator in the message Body
In this example, the
eventDiscriminator
is absent, and event discrimination defaults to exploiting the discriminator defined in the schema for the body parameter.The text was updated successfully, but these errors were encountered: