Skip to content

Commit 2374f9a

Browse files
Update API definitions
1 parent 74b4377 commit 2374f9a

File tree

6 files changed

+2168
-0
lines changed

6 files changed

+2168
-0
lines changed

tests/.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copy and rename to .env
2+
REBILLY_API_KEY=sk_live_D6F95HMCUtestKey
3+
ORGANIZAION_ID==org_01H4JHB8A4BGJ3EFS390671GYY
4+
REBILLY_API_URL=https://api.local.rebilly.dev/organizations/{organizationId}

tests/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
openapi.yaml
3+
/node_modules

tests/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"scripts": {
3+
"fetch": "node --experimental-modules scripts/fetch.mjs",
4+
"test": "export $(grep -vvv '^#' .env | xargs) && redocly respect -S \"{\\\"Rebilly\\\": \\\"$REBILLY_API_URL\\\"}\" smoke-tests.arazzo.yaml"
5+
},
6+
"dependencies": {
7+
"@redocly/cli": "^1.32.1",
8+
"axios": "^1.7.4",
9+
"lodash": "^4.17.21",
10+
"yaml": "^2.7.0"
11+
}
12+
}

tests/scripts/fetch.mjs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import axios from 'axios';
2+
import fs from 'fs/promises';
3+
import { parse, stringify } from 'yaml'
4+
import set from "lodash/set.js"
5+
6+
const sourceUrl = 'https://www.rebilly.com/_spec/catalog/all.yaml';
7+
const destinationFile = './openapi.yaml';
8+
9+
const response = await axios.get(sourceUrl);
10+
11+
const schema = parse(response.data);
12+
13+
/*
14+
* Some fields in the API are returned for backwards compatibility,
15+
* but should not appear in the API definitions.
16+
* We manually add them here to the definitions so that the schema check does not fail
17+
*/
18+
const hiddenDeprecatedProperties = [
19+
{
20+
path: 'components.schemas.Coupon.properties.redemptionCode',
21+
definition: {
22+
type: 'string',
23+
},
24+
},
25+
{
26+
path: 'components.schemas.VaultedInstrument.properties.paymentCardId',
27+
definition: {
28+
type: 'string',
29+
},
30+
},
31+
{
32+
path: 'components.schemas.VaultedInstrument.properties.payPalAccountId',
33+
definition: {
34+
type: 'string',
35+
},
36+
},
37+
{
38+
path: 'components.schemas.VaultedInstrument.properties.bankAccountId',
39+
definition: {
40+
type: 'string',
41+
},
42+
},
43+
]
44+
45+
hiddenDeprecatedProperties.forEach(({path, definition}) => {
46+
set(schema, path, definition);
47+
})
48+
49+
50+
await fs.writeFile(destinationFile, stringify(schema));

tests/smoke-tests.arazzo.yaml

+314
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
arazzo: 1.0.1
2+
3+
info:
4+
title: Rebilly workflows
5+
version: 1.0.0
6+
7+
sourceDescriptions:
8+
- name: Rebilly
9+
type: openapi
10+
url: ./openapi.yaml
11+
12+
components:
13+
inputs:
14+
env:
15+
properties:
16+
REBILLY_ORGANIZATION:
17+
type: string
18+
REBILLY_API_KEY:
19+
type: string
20+
format: password
21+
parameters:
22+
apiKey:
23+
in: header
24+
name: REB-APIKEY
25+
value: $inputs.env.REBILLY_API_KEY
26+
organizationId:
27+
in: path
28+
name: organizationId
29+
value: $inputs.env.REBILLY_ORGANIZATION
30+
31+
workflows:
32+
- workflowId: rebilly-api/status
33+
inputs:
34+
properties:
35+
$ref: '#/components/inputs'
36+
parameters:
37+
- reference: $components.parameters.apiKey
38+
- reference: $components.parameters.organizationId
39+
steps:
40+
- stepId: GetStatus
41+
operationId: GetStatus
42+
successCriteria:
43+
- condition: $statusCode == 200
44+
45+
- workflowId: rebilly-api/attachments
46+
47+
inputs:
48+
properties:
49+
$ref: '#/components/inputs'
50+
parameters:
51+
- reference: $components.parameters.apiKey
52+
- reference: $components.parameters.organizationId
53+
steps:
54+
- stepId: GetAttachmentCollection
55+
operationId: GetAttachmentCollection
56+
successCriteria:
57+
- condition: $statusCode == 200
58+
59+
- workflowId: rebilly-api/files
60+
61+
inputs:
62+
properties:
63+
$ref: '#/components/inputs'
64+
parameters:
65+
- reference: $components.parameters.apiKey
66+
- reference: $components.parameters.organizationId
67+
steps:
68+
- stepId: GetFileCollection
69+
operationId: GetFileCollection
70+
successCriteria:
71+
- condition: $statusCode == 200
72+
73+
- workflowId: rebilly-api/applications
74+
75+
inputs:
76+
properties:
77+
$ref: '#/components/inputs'
78+
parameters:
79+
- reference: $components.parameters.apiKey
80+
- reference: $components.parameters.organizationId
81+
steps:
82+
- stepId: GetApplicationCollection
83+
operationId: GetApplicationCollection
84+
successCriteria:
85+
- condition: $statusCode == 200
86+
87+
- workflowId: rebilly-api/customers
88+
89+
inputs:
90+
properties:
91+
$ref: '#/components/inputs'
92+
parameters:
93+
- reference: $components.parameters.apiKey
94+
- reference: $components.parameters.organizationId
95+
steps:
96+
- stepId: GetCustomerCollection
97+
operationId: GetCustomerCollection
98+
successCriteria:
99+
- condition: $statusCode == 200
100+
101+
- workflowId: rebilly-api/custom-fields
102+
103+
inputs:
104+
properties:
105+
$ref: '#/components/inputs'
106+
parameters:
107+
- reference: $components.parameters.apiKey
108+
- reference: $components.parameters.organizationId
109+
steps:
110+
- stepId: GetCustomFieldCollection
111+
operationId: GetCustomFieldCollection
112+
parameters:
113+
- name: resource
114+
in: path
115+
value: customers
116+
successCriteria:
117+
- condition: $statusCode == 200
118+
119+
- workflowId: rebilly-api/webhooks
120+
121+
inputs:
122+
properties:
123+
$ref: '#/components/inputs'
124+
parameters:
125+
- reference: $components.parameters.apiKey
126+
- reference: $components.parameters.organizationId
127+
steps:
128+
- stepId: GetWebhookCollection
129+
operationId: GetWebhookCollection
130+
successCriteria:
131+
- condition: $statusCode == 200
132+
133+
- workflowId: rebilly-api/events
134+
135+
inputs:
136+
properties:
137+
$ref: '#/components/inputs'
138+
parameters:
139+
- reference: $components.parameters.apiKey
140+
- reference: $components.parameters.organizationId
141+
steps:
142+
- stepId: GetEventCollection
143+
operationId: GetEventCollection
144+
successCriteria:
145+
- condition: $statusCode == 200
146+
147+
- workflowId: rebilly-api/websites
148+
149+
inputs:
150+
properties:
151+
$ref: '#/components/inputs'
152+
parameters:
153+
- reference: $components.parameters.apiKey
154+
- reference: $components.parameters.organizationId
155+
steps:
156+
- stepId: GetWebsiteCollection
157+
operationId: GetWebsiteCollection
158+
successCriteria:
159+
- condition: $statusCode == 200
160+
161+
- workflowId: rebilly-api/api-keys
162+
163+
inputs:
164+
properties:
165+
$ref: '#/components/inputs'
166+
parameters:
167+
- reference: $components.parameters.apiKey
168+
- reference: $components.parameters.organizationId
169+
steps:
170+
- stepId: GetApiKeyCollection
171+
operationId: GetApiKeyCollection
172+
successCriteria:
173+
- condition: $statusCode == 200
174+
175+
- workflowId: rebilly-api/tags
176+
177+
inputs:
178+
properties:
179+
$ref: '#/components/inputs'
180+
parameters:
181+
- reference: $components.parameters.apiKey
182+
- reference: $components.parameters.organizationId
183+
steps:
184+
- stepId: GetTagCollection
185+
operationId: GetTagCollection
186+
successCriteria:
187+
- condition: $statusCode == 200
188+
189+
- workflowId: rebilly-api/fees
190+
191+
inputs:
192+
properties:
193+
$ref: '#/components/inputs'
194+
parameters:
195+
- reference: $components.parameters.apiKey
196+
- reference: $components.parameters.organizationId
197+
steps:
198+
- stepId: GetFeeCollection
199+
operationId: GetFeeCollection
200+
successCriteria:
201+
- condition: $statusCode == 200
202+
203+
- workflowId: rebilly-api/custom-domains
204+
205+
inputs:
206+
properties:
207+
$ref: '#/components/inputs'
208+
parameters:
209+
- reference: $components.parameters.apiKey
210+
- reference: $components.parameters.organizationId
211+
steps:
212+
- stepId: GetCustomDomainCollection
213+
operationId: GetCustomDomainCollection
214+
successCriteria:
215+
- condition: $statusCode == 200
216+
217+
- workflowId: rebilly-api/shipping-rates
218+
219+
inputs:
220+
properties:
221+
$ref: '#/components/inputs'
222+
parameters:
223+
- reference: $components.parameters.apiKey
224+
- reference: $components.parameters.organizationId
225+
steps:
226+
- stepId: GetShippingRateCollection
227+
operationId: GetShippingRateCollection
228+
successCriteria:
229+
- condition: $statusCode == 200
230+
231+
- workflowId: rebilly-api/roles
232+
233+
inputs:
234+
properties:
235+
$ref: '#/components/inputs'
236+
parameters:
237+
- reference: $components.parameters.apiKey
238+
- reference: $components.parameters.organizationId
239+
steps:
240+
- stepId: GetRoleCollection
241+
operationId: GetRoleCollection
242+
successCriteria:
243+
- condition: $statusCode == 200
244+
245+
- workflowId: rebilly-api/profile
246+
247+
inputs:
248+
properties:
249+
$ref: '#/components/inputs'
250+
parameters:
251+
- reference: $components.parameters.apiKey
252+
- reference: $components.parameters.organizationId
253+
steps:
254+
- stepId: GetProfile
255+
operationId: GetProfile
256+
successCriteria:
257+
- condition: $statusCode == 200
258+
259+
- workflowId: rebilly-api/tags-rules
260+
261+
inputs:
262+
properties:
263+
$ref: '#/components/inputs'
264+
parameters:
265+
- reference: $components.parameters.apiKey
266+
- reference: $components.parameters.organizationId
267+
steps:
268+
- stepId: GetTagRuleCollection
269+
operationId: GetTagRuleCollection
270+
successCriteria:
271+
- condition: $statusCode == 200
272+
273+
- workflowId: rebilly-api/coupons
274+
275+
inputs:
276+
properties:
277+
$ref: '#/components/inputs'
278+
parameters:
279+
- reference: $components.parameters.apiKey
280+
- reference: $components.parameters.organizationId
281+
steps:
282+
- stepId: GetCouponCollection
283+
operationId: GetCouponCollection
284+
successCriteria:
285+
- condition: $statusCode == 200
286+
287+
- workflowId: rebilly-api/payment-gateways-metadata
288+
289+
inputs:
290+
properties:
291+
$ref: '#/components/inputs'
292+
parameters:
293+
- reference: $components.parameters.apiKey
294+
- reference: $components.parameters.organizationId
295+
steps:
296+
- stepId: GetPaymentGatewayMetadataCollection
297+
operationId: GetPaymentGatewayMetadataCollection
298+
successCriteria:
299+
- condition: $statusCode == 200
300+
301+
- workflowId: rebilly-api/products
302+
303+
inputs:
304+
properties:
305+
$ref: '#/components/inputs'
306+
parameters:
307+
- reference: $components.parameters.apiKey
308+
- reference: $components.parameters.organizationId
309+
steps:
310+
- stepId: GetProductCollection
311+
operationId: GetProductCollection
312+
313+
successCriteria:
314+
- condition: $statusCode == 200

0 commit comments

Comments
 (0)