Skip to content

Commit 709b01d

Browse files
authored
Webhooks - Add string enum types and update preview docs (#773)
* feat: add string enums to webhook field types * chore: add extra docs on previewing open api specs
1 parent 2be7572 commit 709b01d

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,27 @@ BREAKING CHANGE: use JavaScript features not available in Node 6
6363
We are using [OpenAPI generator](https://github.com/OpenAPITools/openapi-generator) along with these OAS yaml files to generate our new SDKs.
6464

6565
## Preview
66+
### Online
6667
There are lots of tools available for viewing and editing OpenAPI descriptions in a nicely formatted way. A popular tool is SwaggerHub - a version of which is [hosted here](https://app.swaggerhub.com/home).
6768

6869
Once you sign up or login, you can create a new API under your account and import a Xero API spec.
6970

7071
![SwaggerUI Example](images/import-api.png)
7172

73+
### Local
74+
75+
#### Node.js
76+
If you have Node.js you can use the Swagger UI via an NPM package (it will open a webpage in your default browser):
77+
`npx -y open-swagger-ui --open ./xero_accounting.yaml`
78+
79+
#### Docker
80+
To view a local file via Docker, run:
81+
`docker run -p 8080:8080 -e SWAGGER_JSON=/local/xero_accounting.yaml -v $PWD:/local docker.swagger.io/swaggerapi/swagger-ui`
82+
83+
To view a hosted file via Docker, run:
84+
`docker run -p 8080:8080 -e SWAGGER_JSON_URL=https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/refs/heads/master/xero_accounting.yaml docker.swagger.io/swaggerapi/swagger-ui`
85+
86+
7287
## Updates
7388
If you find something missing or incorrect please [open an issue](https://github.com/XeroAPI/Xero-OpenAPI/issues/new) or send us a pull request.
7489

xero-webhooks.yaml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
openapi: 3.1.1
22
info:
3-
description: The Xero Webhooks API exposes event notifications relating to entities in the Xero Public API and can be used for a variety of purposes.
3+
description: The Xero Webhooks API exposes event notifications relating to entities in the Xero Public API and can be used for a variety of purposes
44
title: Xero Webhooks API
55
version: 9.2.0
66
termsOfService: https://developer.xero.com/xero-developer-platform-terms-conditions/
@@ -9,8 +9,9 @@ info:
99
1010
url: https://developer.xero.com
1111
servers:
12-
- description: The Xero Webhooks API exposes event notifications relating to entities in the Xero Public API and can be used for a variety of purposes.
12+
- description: The Xero Webhooks API exposes event notifications relating to entities in the Xero Public API and can be used for a variety of purposes
1313
url: https://api.xero.com
14+
security: []
1415
webhooks:
1516
invoices:
1617
post:
@@ -97,17 +98,41 @@ components:
9798
description: The date and time that event occurred (UTC time)
9899
eventType:
99100
type: string
100-
description: The type of event of that occurred (e.g. Update)
101+
description: The type of event of that occurred (e.g. UPDATE)
102+
oneOf:
103+
- type: string
104+
const: CREATE
105+
description: When a new resource is created
106+
- type: string
107+
const: UPDATE
108+
description: When an existing resource is updated (including when they are archived)
101109
eventCategory:
102110
type: string
103-
description: The category of event that occurred (e.g. CONTACT). You will only retrieve events from categories that your webhook is subscribed to.
111+
description: The category of event that occurred (e.g. CONTACT). You will only retrieve events from categories that your webhook is subscribed to
112+
oneOf:
113+
- type: string
114+
const: CONTACT
115+
description: For organisation contact-related events
116+
- type: string
117+
const: INVOICE
118+
description: For organisation invoice-related events
119+
- type: string
120+
const: SUBSCRIPTION
121+
description: For application subscription-related events
104122
tenantId:
105123
type: string
106124
format: uuid
107125
description: The ID of the tenant that the event happened in relation to (OrganisationID or ApplicationID)
108126
tenantType:
109127
type: string
110-
description: The type of tenant, depending on the type of event it will be one of ORGANISATION (for Contact or Invoice events), or APPLICATION (for Subscription events)
128+
description: The type of tenant
129+
oneOf:
130+
- type: string
131+
const: ORGANISATION
132+
description: Represents a Xero organisation (for non-Subscription events)
133+
- type: string
134+
const: APPLICATION
135+
description: Represents a Xero application (for Subscription events)
111136
required:
112137
- resourceUrl
113138
- resourceId
@@ -116,20 +141,20 @@ components:
116141
- eventCategory
117142
- tenantId
118143
- tenantType
119-
description: A list of events that have occurred.
144+
description: A list of events that have occurred
120145
lastEventSequence:
121146
type: integer
122147
minimum: 1
123148
maximum: 2147483647
124-
description: The sequence number of the last event in the list.
149+
description: The sequence number of the last event in the list
125150
firstEventSequence:
126151
type: integer
127152
minimum: 1
128153
maximum: 2147483647
129-
description: The sequence number of the first event in the list.
154+
description: The sequence number of the first event in the list
130155
entropy:
131156
type: string
132-
description: A random string used for security or validation purposes.
157+
description: A random string used for security or validation purposes
133158
responses:
134159
401InvalidWebhookData:
135160
description: Return a 401 status to indicate that the webhook subscription failed

0 commit comments

Comments
 (0)