@schmock/openapi 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/crud-detector.d.ts +35 -0
  2. package/dist/crud-detector.d.ts.map +1 -0
  3. package/dist/crud-detector.js +153 -0
  4. package/dist/generators.d.ts +14 -0
  5. package/dist/generators.d.ts.map +1 -0
  6. package/dist/generators.js +158 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +221 -0
  10. package/dist/normalizer.d.ts +14 -0
  11. package/dist/normalizer.d.ts.map +1 -0
  12. package/dist/normalizer.js +194 -0
  13. package/dist/parser.d.ts +32 -0
  14. package/dist/parser.d.ts.map +1 -0
  15. package/dist/parser.js +282 -0
  16. package/dist/plugin.d.ts +32 -0
  17. package/dist/plugin.d.ts.map +1 -0
  18. package/dist/plugin.js +129 -0
  19. package/dist/seed.d.ts +15 -0
  20. package/dist/seed.d.ts.map +1 -0
  21. package/dist/seed.js +41 -0
  22. package/package.json +45 -0
  23. package/src/__fixtures__/faker-stress-test.openapi.yaml +1030 -0
  24. package/src/__fixtures__/openapi31.json +34 -0
  25. package/src/__fixtures__/petstore-openapi3.json +168 -0
  26. package/src/__fixtures__/petstore-swagger2.json +141 -0
  27. package/src/__fixtures__/scalar-galaxy.yaml +1314 -0
  28. package/src/__fixtures__/stripe-fixtures3.json +6542 -0
  29. package/src/__fixtures__/stripe-spec3.yaml +161621 -0
  30. package/src/__fixtures__/train-travel.yaml +1264 -0
  31. package/src/crud-detector.test.ts +150 -0
  32. package/src/crud-detector.ts +194 -0
  33. package/src/generators.test.ts +214 -0
  34. package/src/generators.ts +212 -0
  35. package/src/index.ts +4 -0
  36. package/src/normalizer.test.ts +253 -0
  37. package/src/normalizer.ts +233 -0
  38. package/src/parser.test.ts +181 -0
  39. package/src/parser.ts +389 -0
  40. package/src/plugin.test.ts +205 -0
  41. package/src/plugin.ts +185 -0
  42. package/src/seed.ts +62 -0
  43. package/src/steps/openapi-crud.steps.ts +132 -0
  44. package/src/steps/openapi-parsing.steps.ts +111 -0
  45. package/src/steps/openapi-seed.steps.ts +94 -0
  46. package/src/stress.test.ts +2814 -0
@@ -0,0 +1,1264 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Train Travel API
4
+ description: |
5
+ API for finding and booking train trips across Europe.
6
+
7
+ ## Run in Postman
8
+
9
+ Experiment with this API in Postman, using our Postman Collection.
10
+
11
+ [![Run In Postman](https://run.pstmn.io/button.svg =128pxx32px)](https://app.getpostman.com/run-collection/9265903-7a75a0d0-b108-4436-ba54-c6139698dc08?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D9265903-7a75a0d0-b108-4436-ba54-c6139698dc08%26entityType%3Dcollection%26workspaceId%3Df507f69d-9564-419c-89a2-cb8e4c8c7b8f)
12
+ version: 1.2.1
13
+ contact:
14
+ name: Train Support
15
+ url: https://example.com/support
16
+ email: support@example.com
17
+ license:
18
+ name: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
19
+ identifier: CC-BY-NC-SA-4.0
20
+ x-feedbackLink:
21
+ label: Submit Feedback
22
+ url: https://github.com/bump-sh-examples/train-travel-api/issues/new
23
+
24
+ servers:
25
+ - url: https://try.microcks.io/rest/Train+Travel+API/1.0.0
26
+ description: Mock Server
27
+ x-internal: false
28
+
29
+ - url: https://api.example.com
30
+ description: Production
31
+ x-internal: false
32
+
33
+ x-speakeasy-retries:
34
+ strategy: backoff
35
+ backoff:
36
+ initialInterval: 500 # 500 milliseconds
37
+ maxInterval: 60000 # 60 seconds
38
+ maxElapsedTime: 3600000 # 5 minutes
39
+ exponent: 1.5
40
+ statusCodes:
41
+ - 5XX
42
+ retryConnectionErrors: true
43
+
44
+ security:
45
+ - OAuth2:
46
+ - read
47
+
48
+ x-topics:
49
+ - title: Getting started
50
+ content:
51
+ $ref: ./docs/getting-started.md
52
+
53
+ tags:
54
+ - name: Stations
55
+ description: |
56
+ Find and filter train stations across Europe, including their location
57
+ and local timezone.
58
+ - name: Trips
59
+ description: |
60
+ Timetables and routes for train trips between stations, including pricing
61
+ and availability.
62
+ - name: Bookings
63
+ description: |
64
+ Create and manage bookings for train trips, including passenger details
65
+ and optional extras.
66
+ - name: Payments
67
+ description: |
68
+ Pay for bookings using a card or bank account, and view payment
69
+ status and history.
70
+
71
+ > warn
72
+ > Bookings usually expire within 1 hour so you'll need to make your payment
73
+ > before the expiry date
74
+
75
+ paths:
76
+ /stations:
77
+ get:
78
+ summary: Get a list of train stations
79
+ description: Returns a paginated and searchable list of all train stations.
80
+ operationId: get-stations
81
+ tags:
82
+ - Stations
83
+ parameters:
84
+ - $ref: '#/components/parameters/page'
85
+ - $ref: '#/components/parameters/limit'
86
+ - name: coordinates
87
+ in: query
88
+ description: >
89
+ The latitude and longitude of the user's location, to narrow down
90
+ the search results to sites within a proximity of this location.
91
+ required: false
92
+ schema:
93
+ type: string
94
+ example: 52.5200,13.4050
95
+ - name: search
96
+ in: query
97
+ description: >
98
+ A search term to filter the list of stations by name or address.
99
+ required: false
100
+ schema:
101
+ type: string
102
+ examples:
103
+ - Milano Centrale
104
+ - Paris
105
+ - name: country
106
+ in: query
107
+ description: Filter stations by country code
108
+ required: false
109
+ schema:
110
+ type: string
111
+ format: iso-country-code
112
+ example: DE
113
+ responses:
114
+ '200':
115
+ description: OK
116
+ headers:
117
+ Cache-Control:
118
+ $ref: '#/components/headers/Cache-Control'
119
+ RateLimit:
120
+ $ref: '#/components/headers/RateLimit'
121
+ content:
122
+ application/json:
123
+ schema:
124
+ allOf:
125
+ - $ref: '#/components/schemas/Wrapper-Collection'
126
+ - properties:
127
+ data:
128
+ type: array
129
+ items:
130
+ $ref: '#/components/schemas/Station'
131
+ - properties:
132
+ links:
133
+ allOf:
134
+ - $ref: '#/components/schemas/Links-Self'
135
+ - $ref: '#/components/schemas/Links-Pagination'
136
+ example:
137
+ data:
138
+ - id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
139
+ name: Berlin Hauptbahnhof
140
+ address: Invalidenstraße 10557 Berlin, Germany
141
+ country_code: DE
142
+ timezone: Europe/Berlin
143
+ - id: b2e783e1-c824-4d63-b37a-d8d698862f1d
144
+ name: Paris Gare du Nord
145
+ address: 18 Rue de Dunkerque 75010 Paris, France
146
+ country_code: FR
147
+ timezone: Europe/Paris
148
+ links:
149
+ self: https://api.example.com/stations&page=2
150
+ next: https://api.example.com/stations?page=3
151
+ prev: https://api.example.com/stations?page=1
152
+ application/xml:
153
+ schema:
154
+ allOf:
155
+ - $ref: '#/components/schemas/Wrapper-Collection'
156
+ - properties:
157
+ data:
158
+ type: array
159
+ xml:
160
+ name: stations
161
+ wrapped: true
162
+ items:
163
+ $ref: '#/components/schemas/Station'
164
+ - properties:
165
+ links:
166
+ allOf:
167
+ - $ref: '#/components/schemas/Links-Self'
168
+ - $ref: '#/components/schemas/Links-Pagination'
169
+ '400':
170
+ $ref: '#/components/responses/BadRequest'
171
+ '401':
172
+ $ref: '#/components/responses/Unauthorized'
173
+ '403':
174
+ $ref: '#/components/responses/Forbidden'
175
+ '429':
176
+ $ref: '#/components/responses/TooManyRequests'
177
+ '500':
178
+ $ref: '#/components/responses/InternalServerError'
179
+ /trips:
180
+ get:
181
+ summary: Get available train trips
182
+ description: >
183
+ Returns a list of available train trips between the specified origin and
184
+ destination stations on the given date, and allows for filtering by
185
+ bicycle and dog allowances.
186
+ operationId: get-trips
187
+ tags:
188
+ - Trips
189
+ parameters:
190
+ - $ref: '#/components/parameters/page'
191
+ - $ref: '#/components/parameters/limit'
192
+ - name: origin
193
+ in: query
194
+ description: The ID of the origin station
195
+ required: true
196
+ schema:
197
+ type: string
198
+ format: uuid
199
+ example: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
200
+ - name: destination
201
+ in: query
202
+ description: The ID of the destination station
203
+ required: true
204
+ schema:
205
+ type: string
206
+ format: uuid
207
+ example: b2e783e1-c824-4d63-b37a-d8d698862f1d
208
+ - name: date
209
+ in: query
210
+ description: The date and time of the trip in ISO 8601 format in origin station's timezone.
211
+ required: true
212
+ schema:
213
+ type: string
214
+ format: date-time
215
+ example: '2024-02-01T09:00:00Z'
216
+ - name: bicycles
217
+ in: query
218
+ description: Only return trips where bicycles are known to be allowed
219
+ required: false
220
+ schema:
221
+ type: boolean
222
+ default: false
223
+ - name: dogs
224
+ in: query
225
+ description: Only return trips where dogs are known to be allowed
226
+ required: false
227
+ schema:
228
+ type: boolean
229
+ default: false
230
+ responses:
231
+ '200':
232
+ description: A list of available train trips
233
+ headers:
234
+ Cache-Control:
235
+ $ref: '#/components/headers/Cache-Control'
236
+ RateLimit:
237
+ $ref: '#/components/headers/RateLimit'
238
+ content:
239
+ application/json:
240
+ schema:
241
+ allOf:
242
+ - $ref: '#/components/schemas/Wrapper-Collection'
243
+ - properties:
244
+ data:
245
+ type: array
246
+ items:
247
+ allOf:
248
+ - $ref: '#/components/schemas/Trip'
249
+ - $ref: '#/components/schemas/Links-Origin'
250
+ - $ref: '#/components/schemas/Links-Destination'
251
+ - properties:
252
+ links:
253
+ allOf:
254
+ - $ref: '#/components/schemas/Links-Self'
255
+ - $ref: '#/components/schemas/Links-Pagination'
256
+ example:
257
+ data:
258
+ - id: ea399ba1-6d95-433f-92d1-83f67b775594
259
+ origin: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
260
+ destination: b2e783e1-c824-4d63-b37a-d8d698862f1d
261
+ departure_time: '2024-02-01T10:00:00Z'
262
+ arrival_time: '2024-02-01T16:00:00Z'
263
+ price: 50
264
+ operator: Deutsche Bahn
265
+ bicycles_allowed: true
266
+ dogs_allowed: true
267
+ links:
268
+ self: https://api.example.com/trips/ea399ba1-6d95-433f-92d1-83f67b775594
269
+ origin: https://api.example.com/stations/efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
270
+ destination: https://api.example.com/stations/b2e783e1-c824-4d63-b37a-d8d698862f1d
271
+ - id: 4d67459c-af07-40bb-bb12-178dbb88e09f
272
+ origin: b2e783e1-c824-4d63-b37a-d8d698862f1d
273
+ destination: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
274
+ departure_time: '2024-02-01T12:00:00Z'
275
+ arrival_time: '2024-02-01T18:00:00Z'
276
+ price: 50
277
+ operator: SNCF
278
+ bicycles_allowed: true
279
+ dogs_allowed: true
280
+ links:
281
+ self: https://api.example.com/trips/4d67459c-af07-40bb-bb12-178dbb88e09f
282
+ origin: https://api.example.com/stations/b2e783e1-c824-4d63-b37a-d8d698862f1d
283
+ destination: https://api.example.com/stations/efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
284
+ links:
285
+ self: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01
286
+ next: https://api.example.com/trips?origin=efdbb9d1-02c2-4bc3-afb7-6788d8782b1e&destination=b2e783e1-c824-4d63-b37a-d8d698862f1d&date=2024-02-01&page=2
287
+ application/xml:
288
+ schema:
289
+ allOf:
290
+ - $ref: '#/components/schemas/Wrapper-Collection'
291
+ - properties:
292
+ data:
293
+ type: array
294
+ xml:
295
+ name: trips
296
+ wrapped: true
297
+ items:
298
+ $ref: '#/components/schemas/Trip'
299
+ - properties:
300
+ links:
301
+ allOf:
302
+ - $ref: '#/components/schemas/Links-Self'
303
+ - $ref: '#/components/schemas/Links-Pagination'
304
+ '400':
305
+ $ref: '#/components/responses/BadRequest'
306
+ '401':
307
+ $ref: '#/components/responses/Unauthorized'
308
+ '403':
309
+ $ref: '#/components/responses/Forbidden'
310
+ '429':
311
+ $ref: '#/components/responses/TooManyRequests'
312
+ '500':
313
+ $ref: '#/components/responses/InternalServerError'
314
+ /bookings:
315
+ get:
316
+ operationId: get-bookings
317
+ summary: List existing bookings
318
+ description: Returns a list of all trip bookings by the authenticated user.
319
+ tags:
320
+ - Bookings
321
+ parameters:
322
+ - $ref: '#/components/parameters/page'
323
+ - $ref: '#/components/parameters/limit'
324
+ responses:
325
+ '200':
326
+ description: A list of bookings
327
+ headers:
328
+ Cache-Control:
329
+ $ref: '#/components/headers/Cache-Control'
330
+ RateLimit:
331
+ $ref: '#/components/headers/RateLimit'
332
+ content:
333
+ application/json:
334
+ schema:
335
+ allOf:
336
+ - $ref: '#/components/schemas/Wrapper-Collection'
337
+ - properties:
338
+ data:
339
+ type: array
340
+ items:
341
+ $ref: '#/components/schemas/Booking'
342
+ - properties:
343
+ links:
344
+ allOf:
345
+ - $ref: '#/components/schemas/Links-Self'
346
+ - $ref: '#/components/schemas/Links-Pagination'
347
+ example:
348
+ data:
349
+ - id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
350
+ trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
351
+ passenger_name: John Doe
352
+ has_bicycle: true
353
+ has_dog: true
354
+ - id: b2e783e1-c824-4d63-b37a-d8d698862f1d
355
+ trip_id: b2e783e1-c824-4d63-b37a-d8d698862f1d
356
+ passenger_name: Jane Smith
357
+ has_bicycle: false
358
+ has_dog: false
359
+ links:
360
+ self: https://api.example.com/bookings
361
+ next: https://api.example.com/bookings?page=2
362
+ application/xml:
363
+ schema:
364
+ allOf:
365
+ - $ref: '#/components/schemas/Wrapper-Collection'
366
+ - properties:
367
+ data:
368
+ type: array
369
+ xml:
370
+ name: bookings
371
+ wrapped: true
372
+ items:
373
+ $ref: '#/components/schemas/Booking'
374
+ - properties:
375
+ links:
376
+ allOf:
377
+ - $ref: '#/components/schemas/Links-Self'
378
+ - $ref: '#/components/schemas/Links-Pagination'
379
+ '400':
380
+ $ref: '#/components/responses/BadRequest'
381
+ '401':
382
+ $ref: '#/components/responses/Unauthorized'
383
+ '403':
384
+ $ref: '#/components/responses/Forbidden'
385
+ '429':
386
+ $ref: '#/components/responses/TooManyRequests'
387
+ '500':
388
+ $ref: '#/components/responses/InternalServerError'
389
+
390
+ post:
391
+ operationId: create-booking
392
+ summary: Create a booking
393
+ description: A booking is a temporary hold on a trip. It is not confirmed until the payment is processed.
394
+ tags:
395
+ - Bookings
396
+ security:
397
+ - OAuth2:
398
+ - write
399
+ requestBody:
400
+ description: Booking details
401
+ required: true
402
+ content:
403
+ application/json:
404
+ schema:
405
+ $ref: '#/components/schemas/Booking'
406
+ application/xml:
407
+ schema:
408
+ $ref: '#/components/schemas/Booking'
409
+ responses:
410
+ '201':
411
+ description: Booking successful
412
+ content:
413
+ application/json:
414
+ schema:
415
+ allOf:
416
+ - $ref: '#/components/schemas/Booking'
417
+ - properties:
418
+ links:
419
+ $ref: '#/components/schemas/Links-Self'
420
+
421
+ example:
422
+ id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
423
+ trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
424
+ passenger_name: John Doe
425
+ has_bicycle: true
426
+ has_dog: true
427
+ links:
428
+ self: https://api.example.com/bookings/efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
429
+ application/xml:
430
+ schema:
431
+ allOf:
432
+ - $ref: '#/components/schemas/Booking'
433
+ - properties:
434
+ links:
435
+ $ref: '#/components/schemas/Links-Self'
436
+ '400':
437
+ $ref: '#/components/responses/BadRequest'
438
+ '401':
439
+ $ref: '#/components/responses/Unauthorized'
440
+ '404':
441
+ $ref: '#/components/responses/NotFound'
442
+ '409':
443
+ $ref: '#/components/responses/Conflict'
444
+ '429':
445
+ $ref: '#/components/responses/TooManyRequests'
446
+ '500':
447
+ $ref: '#/components/responses/InternalServerError'
448
+
449
+ /bookings/{bookingId}:
450
+ parameters:
451
+ - name: bookingId
452
+ in: path
453
+ required: true
454
+ description: The ID of the booking to retrieve.
455
+ schema:
456
+ type: string
457
+ format: uuid
458
+ example: 1725ff48-ab45-4bb5-9d02-88745177dedb
459
+ get:
460
+ summary: Get a booking
461
+ description: Returns the details of a specific booking.
462
+ operationId: get-booking
463
+ tags:
464
+ - Bookings
465
+ responses:
466
+ '200':
467
+ description: The booking details
468
+ headers:
469
+ Cache-Control:
470
+ $ref: '#/components/headers/Cache-Control'
471
+ RateLimit:
472
+ $ref: '#/components/headers/RateLimit'
473
+ content:
474
+ application/json:
475
+ schema:
476
+ allOf:
477
+ - $ref: '#/components/schemas/Booking'
478
+ - properties:
479
+ links:
480
+ $ref: '#/components/schemas/Links-Self'
481
+ example:
482
+ id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
483
+ trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
484
+ passenger_name: John Doe
485
+ has_bicycle: true
486
+ has_dog: true
487
+ links:
488
+ self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
489
+ application/xml:
490
+ schema:
491
+ allOf:
492
+ - $ref: '#/components/schemas/Booking'
493
+ - properties:
494
+ links:
495
+ $ref: '#/components/schemas/Links-Self'
496
+ '400':
497
+ $ref: '#/components/responses/BadRequest'
498
+ '401':
499
+ $ref: '#/components/responses/Unauthorized'
500
+ '403':
501
+ $ref: '#/components/responses/Forbidden'
502
+ '404':
503
+ $ref: '#/components/responses/NotFound'
504
+ '429':
505
+ $ref: '#/components/responses/TooManyRequests'
506
+ '500':
507
+ $ref: '#/components/responses/InternalServerError'
508
+ delete:
509
+ summary: Delete a booking
510
+ description: Deletes a booking, cancelling the hold on the trip.
511
+ operationId: delete-booking
512
+ security:
513
+ - OAuth2:
514
+ - write
515
+ tags:
516
+ - Bookings
517
+ responses:
518
+ '204':
519
+ description: Booking deleted
520
+ '400':
521
+ $ref: '#/components/responses/BadRequest'
522
+ '401':
523
+ $ref: '#/components/responses/Unauthorized'
524
+ '403':
525
+ $ref: '#/components/responses/Forbidden'
526
+ '404':
527
+ $ref: '#/components/responses/NotFound'
528
+ '429':
529
+ $ref: '#/components/responses/TooManyRequests'
530
+ '500':
531
+ $ref: '#/components/responses/InternalServerError'
532
+
533
+ /bookings/{bookingId}/payment:
534
+ parameters:
535
+ - name: bookingId
536
+ in: path
537
+ required: true
538
+ description: The ID of the booking to pay for.
539
+ schema:
540
+ type: string
541
+ format: uuid
542
+ example: 1725ff48-ab45-4bb5-9d02-88745177dedb
543
+ post:
544
+ summary: Pay for a Booking
545
+ description: A payment is an attempt to pay for the booking, which will confirm the booking for the user and enable them to get their tickets.
546
+ operationId: create-booking-payment
547
+ tags:
548
+ - Payments
549
+ requestBody:
550
+ description: Payment details
551
+ required: true
552
+ content:
553
+ application/json:
554
+ schema:
555
+ $ref: '#/components/schemas/BookingPayment'
556
+ examples:
557
+ Card:
558
+ summary: Card Payment
559
+ value:
560
+ amount: 49.99
561
+ currency: gbp
562
+ source:
563
+ object: card
564
+ name: J. Doe
565
+ number: '4242424242424242'
566
+ cvc: '123'
567
+ exp_month: 12
568
+ exp_year: 2025
569
+ address_line1: 123 Fake Street
570
+ address_line2: 4th Floor
571
+ address_city: London
572
+ address_country: gb
573
+ address_post_code: N12 9XX
574
+ Bank:
575
+ summary: Bank Account Payment
576
+ value:
577
+ amount: 100.5
578
+ currency: gbp
579
+ source:
580
+ object: bank_account
581
+ name: J. Doe
582
+ number: '00012345'
583
+ sort_code: '000123'
584
+ account_type: individual
585
+ bank_name: Starling Bank
586
+ country: gb
587
+ responses:
588
+ '200':
589
+ description: Payment successful
590
+ headers:
591
+ Cache-Control:
592
+ $ref: '#/components/headers/Cache-Control'
593
+ RateLimit:
594
+ $ref: '#/components/headers/RateLimit'
595
+ content:
596
+ application/json:
597
+ schema:
598
+ allOf:
599
+ - $ref: '#/components/schemas/BookingPayment'
600
+ - properties:
601
+ links:
602
+ $ref: '#/components/schemas/Links-Booking'
603
+ examples:
604
+ Card:
605
+ summary: Card Payment
606
+ value:
607
+ id: 2e3b4f5a-6b7c-8d9e-0f1a-2b3c4d5e6f7a
608
+ amount: 49.99
609
+ currency: gbp
610
+ source:
611
+ object: card
612
+ name: J. Doe
613
+ number: '************4242'
614
+ cvc: '123'
615
+ exp_month: 12
616
+ exp_year: 2025
617
+ address_country: gb
618
+ address_post_code: N12 9XX
619
+ status: succeeded
620
+ links:
621
+ booking: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb/payment
622
+ Bank:
623
+ summary: Bank Account Payment
624
+ value:
625
+ id: 2e3b4f5a-6b7c-8d9e-0f1a-2b3c4d5e6f7a
626
+ amount: 100.5
627
+ currency: gbp
628
+ source:
629
+ object: bank_account
630
+ name: J. Doe
631
+ account_type: individual
632
+ number: '*********2345'
633
+ sort_code: '000123'
634
+ bank_name: Starling Bank
635
+ country: gb
636
+ status: succeeded
637
+ links:
638
+ booking: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
639
+ '400':
640
+ $ref: '#/components/responses/BadRequest'
641
+ '401':
642
+ $ref: '#/components/responses/Unauthorized'
643
+ '403':
644
+ $ref: '#/components/responses/Forbidden'
645
+ '429':
646
+ $ref: '#/components/responses/TooManyRequests'
647
+ '500':
648
+ $ref: '#/components/responses/InternalServerError'
649
+ webhooks:
650
+ newBooking:
651
+ post:
652
+ operationId: new-booking
653
+ summary: New Booking
654
+ description: |
655
+ Subscribe to new bookings being created, to update integrations for your users. Related data is available via the links provided in the request.
656
+ tags:
657
+ - Bookings
658
+ requestBody:
659
+ required: true
660
+ content:
661
+ application/json:
662
+ schema:
663
+ allOf:
664
+ - $ref: '#/components/schemas/Booking'
665
+ - properties:
666
+ links:
667
+ allOf:
668
+ - $ref: '#/components/schemas/Links-Self'
669
+ - $ref: '#/components/schemas/Links-Pagination'
670
+ example:
671
+ id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
672
+ trip_id: efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
673
+ passenger_name: John Doe
674
+ has_bicycle: true
675
+ has_dog: true
676
+ links:
677
+ self: https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
678
+ responses:
679
+ '200':
680
+ description: Return a 200 status to indicate that the data was received successfully.
681
+
682
+ components:
683
+ parameters:
684
+ page:
685
+ name: page
686
+ in: query
687
+ description: The page number to return
688
+ required: false
689
+ schema:
690
+ type: integer
691
+ minimum: 1
692
+ default: 1
693
+ example: 1
694
+
695
+ limit:
696
+ name: limit
697
+ in: query
698
+ description: The number of items to return per page
699
+ required: false
700
+ schema:
701
+ type: integer
702
+ minimum: 1
703
+ maximum: 100
704
+ default: 10
705
+ example: 10
706
+
707
+ securitySchemes:
708
+ OAuth2:
709
+ type: oauth2
710
+ description: OAuth 2.0 authorization code following RFC8725 best practices.
711
+ flows:
712
+ authorizationCode:
713
+ authorizationUrl: https://example.com/oauth/authorize
714
+ tokenUrl: https://example.com/oauth/token
715
+ scopes:
716
+ read: Read access
717
+ write: Write access
718
+ schemas:
719
+ Station:
720
+ description: A train station.
721
+ type: object
722
+ xml:
723
+ name: station
724
+ required:
725
+ - id
726
+ - name
727
+ - address
728
+ - country_code
729
+ properties:
730
+ id:
731
+ type: string
732
+ format: uuid
733
+ description: Unique identifier for the station.
734
+ examples:
735
+ - efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
736
+ - b2e783e1-c824-4d63-b37a-d8d698862f1d
737
+ name:
738
+ type: string
739
+ description: The name of the station
740
+ examples:
741
+ - Berlin Hauptbahnhof
742
+ - Paris Gare du Nord
743
+ address:
744
+ type: string
745
+ description: The address of the station.
746
+ examples:
747
+ - Invalidenstraße 10557 Berlin, Germany
748
+ - 18 Rue de Dunkerque 75010 Paris, France
749
+ country_code:
750
+ type: string
751
+ description: The country code of the station.
752
+ format: iso-country-code
753
+ examples:
754
+ - DE
755
+ - FR
756
+ timezone:
757
+ type: string
758
+ description: The timezone of the station in the [IANA Time Zone Database format](https://www.iana.org/time-zones).
759
+ examples:
760
+ - Europe/Berlin
761
+ - Europe/Paris
762
+ Links-Self:
763
+ description: The link to the current resource.
764
+ type: object
765
+ properties:
766
+ self:
767
+ type: string
768
+ format: uri
769
+ Links-Destination:
770
+ description: The link to the destination station resource.
771
+ type: object
772
+ properties:
773
+ self:
774
+ type: string
775
+ format: uri
776
+ Links-Origin:
777
+ description: The link to the origin station resource.
778
+ type: object
779
+ properties:
780
+ self:
781
+ type: string
782
+ format: uri
783
+ Links-Pagination:
784
+ description: Links to the next and previous pages of a paginated response.
785
+ type: object
786
+ properties:
787
+ next:
788
+ type: string
789
+ format: uri
790
+ prev:
791
+ type: string
792
+ format: uri
793
+ Problem:
794
+ description: A problem detail object as defined in RFC 7807.
795
+ type: object
796
+ xml:
797
+ name: problem
798
+ namespace: urn:ietf:rfc:7807
799
+ properties:
800
+ type:
801
+ type: string
802
+ description: A URI reference that identifies the problem type
803
+ examples:
804
+ - https://example.com/probs/out-of-credit
805
+ title:
806
+ type: string
807
+ description: A short, human-readable summary of the problem type
808
+ examples:
809
+ - You do not have enough credit.
810
+ detail:
811
+ type: string
812
+ description: A human-readable explanation specific to this occurrence of the problem
813
+ examples:
814
+ - Your current balance is 30, but that costs 50.
815
+ instance:
816
+ type: string
817
+ description: A URI reference that identifies the specific occurrence of the problem
818
+ examples:
819
+ - /account/12345/msgs/abc
820
+ status:
821
+ type: integer
822
+ description: The HTTP status code
823
+ examples:
824
+ - 400
825
+ Trip:
826
+ description: A train trip.
827
+ type: object
828
+ xml:
829
+ name: trip
830
+ properties:
831
+ id:
832
+ type: string
833
+ format: uuid
834
+ description: Unique identifier for the trip
835
+ examples:
836
+ - 4f4e4e1-c824-4d63-b37a-d8d698862f1d
837
+ origin:
838
+ type: string
839
+ description: The starting station of the trip
840
+ examples:
841
+ - efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
842
+ - b2e783e1-c824-4d63-b37a-d8d698862f1d
843
+ destination:
844
+ type: string
845
+ description: The destination station of the trip
846
+ examples:
847
+ - b2e783e1-c824-4d63-b37a-d8d698862f1d
848
+ - efdbb9d1-02c2-4bc3-afb7-6788d8782b1e
849
+ departure_time:
850
+ type: string
851
+ format: date-time
852
+ description: The date and time when the trip departs
853
+ examples:
854
+ - '2024-02-01T10:00:00Z'
855
+ arrival_time:
856
+ type: string
857
+ format: date-time
858
+ description: The date and time when the trip arrives
859
+ examples:
860
+ - '2024-02-01T16:00:00Z'
861
+ operator:
862
+ type: string
863
+ description: The name of the operator of the trip
864
+ examples:
865
+ - Deutsche Bahn
866
+ - SNCF
867
+ price:
868
+ type: number
869
+ description: The cost of the trip
870
+ examples:
871
+ - 50
872
+ bicycles_allowed:
873
+ type: boolean
874
+ description: Indicates whether bicycles are allowed on the trip
875
+ dogs_allowed:
876
+ type: boolean
877
+ description: Indicates whether dogs are allowed on the trip
878
+ Booking:
879
+ description: A booking for a train trip.
880
+ type: object
881
+ xml:
882
+ name: booking
883
+ properties:
884
+ id:
885
+ type: string
886
+ format: uuid
887
+ description: Unique identifier for the booking
888
+ readOnly: true
889
+ examples:
890
+ - 3f3e3e1-c824-4d63-b37a-d8d698862f1d
891
+ trip_id:
892
+ type: string
893
+ format: uuid
894
+ description: Identifier of the booked trip
895
+ examples:
896
+ - 4f4e4e1-c824-4d63-b37a-d8d698862f1d
897
+ passenger_name:
898
+ type: string
899
+ description: Name of the passenger
900
+ examples:
901
+ - John Doe
902
+ has_bicycle:
903
+ type: boolean
904
+ description: Indicates whether the passenger has a bicycle.
905
+ has_dog:
906
+ type: boolean
907
+ description: Indicates whether the passenger has a dog.
908
+ Wrapper-Collection:
909
+ description: This is a generic request/response wrapper which contains both data and links which serve as hypermedia controls (HATEOAS).
910
+ type: object
911
+ properties:
912
+ data:
913
+ description: The wrapper for a collection is an array of objects.
914
+ type: array
915
+ items:
916
+ type: object
917
+ links:
918
+ description: A set of hypermedia links which serve as controls for the client.
919
+ type: object
920
+ readOnly: true
921
+ xml:
922
+ name: data
923
+ BookingPayment:
924
+ description: A payment for a booking.
925
+ type: object
926
+ properties:
927
+ id:
928
+ description: Unique identifier for the payment. This will be a unique identifier for the payment, and is used to reference the payment in other objects.
929
+ type: string
930
+ format: uuid
931
+ readOnly: true
932
+ amount:
933
+ description: Amount intended to be collected by this payment. A positive decimal figure describing the amount to be collected.
934
+ type: number
935
+ exclusiveMinimum: 0
936
+ examples:
937
+ - 49.99
938
+ currency:
939
+ description: Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
940
+ type: string
941
+ enum:
942
+ - bam
943
+ - bgn
944
+ - chf
945
+ - eur
946
+ - gbp
947
+ - nok
948
+ - sek
949
+ - try
950
+ source:
951
+ unevaluatedProperties: false
952
+ description: The payment source to take the payment from. This can be a card or a bank account. Some of these properties will be hidden on read to protect PII leaking.
953
+ oneOf:
954
+ - title: Card
955
+ description: A card (debit or credit) to take payment from.
956
+ type: object
957
+ properties:
958
+ object:
959
+ type: string
960
+ const: card
961
+ name:
962
+ type: string
963
+ description: Cardholder's full name as it appears on the card.
964
+ examples:
965
+ - Francis Bourgeois
966
+ number:
967
+ type: string
968
+ description: The card number, as a string without any separators. On read all but the last four digits will be masked for security.
969
+ examples:
970
+ - '4242424242424242'
971
+ cvc:
972
+ type: string
973
+ description: Card security code, 3 or 4 digits usually found on the back of the card.
974
+ minLength: 3
975
+ maxLength: 4
976
+ writeOnly: true
977
+
978
+ example: '123'
979
+ exp_month:
980
+ type: integer
981
+ format: int64
982
+ description: Two-digit number representing the card's expiration month.
983
+ examples:
984
+ - 12
985
+ exp_year:
986
+ type: integer
987
+ format: int64
988
+ description: Four-digit number representing the card's expiration year.
989
+ examples:
990
+ - 2025
991
+ address_line1:
992
+ type: string
993
+ writeOnly: true
994
+ address_line2:
995
+ type: string
996
+ writeOnly: true
997
+ address_city:
998
+ type: string
999
+ address_country:
1000
+ type: string
1001
+ address_post_code:
1002
+ type: string
1003
+ required:
1004
+ - name
1005
+ - number
1006
+ - cvc
1007
+ - exp_month
1008
+ - exp_year
1009
+ - address_country
1010
+ - title: Bank Account
1011
+ description: A bank account to take payment from. Must be able to make payments in the currency specified in the payment.
1012
+ type: object
1013
+ properties:
1014
+ object:
1015
+ const: bank_account
1016
+ type: string
1017
+ name:
1018
+ type: string
1019
+ number:
1020
+ type: string
1021
+ description: The account number for the bank account, in string form. Must be a current account.
1022
+ sort_code:
1023
+ type: string
1024
+ description: The sort code for the bank account, in string form. Must be a six-digit number.
1025
+ account_type:
1026
+ enum:
1027
+ - individual
1028
+ - company
1029
+ type: string
1030
+ description: The type of entity that holds the account. This can be either `individual` or `company`.
1031
+ bank_name:
1032
+ type: string
1033
+ description: The name of the bank associated with the routing number.
1034
+ examples:
1035
+ - Starling Bank
1036
+ country:
1037
+ type: string
1038
+ description: Two-letter country code (ISO 3166-1 alpha-2).
1039
+ required:
1040
+ - name
1041
+ - number
1042
+ - account_type
1043
+ - bank_name
1044
+ - country
1045
+ status:
1046
+ description: The status of the payment, one of `pending`, `succeeded`, or `failed`.
1047
+ type: string
1048
+ enum:
1049
+ - pending
1050
+ - succeeded
1051
+ - failed
1052
+ readOnly: true
1053
+ Links-Booking:
1054
+ description: The link to the booking resource.
1055
+ type: object
1056
+ properties:
1057
+ booking:
1058
+ type: string
1059
+ format: uri
1060
+ examples:
1061
+ - https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb
1062
+ headers:
1063
+ Cache-Control:
1064
+ description: |
1065
+ The Cache-Control header communicates directives for caching mechanisms in both requests and responses.
1066
+ It is used to specify the caching directives in responses to prevent caches from storing sensitive information.
1067
+ schema:
1068
+ type: string
1069
+ description: A comma-separated list of directives as defined in [RFC 9111](https://www.rfc-editor.org/rfc/rfc9111.html).
1070
+ examples:
1071
+ - max-age=3600
1072
+ - max-age=604800, public
1073
+ - no-store
1074
+ - no-cache
1075
+ - private
1076
+
1077
+ RateLimit:
1078
+ description: |
1079
+ The RateLimit header communicates quota policies. It contains a `limit` to
1080
+ convey the expiring limit, `remaining` to convey the remaining quota units,
1081
+ and `reset` to convey the time window reset time.
1082
+ schema:
1083
+ type: string
1084
+ examples:
1085
+ - limit=10, remaining=0, reset=10
1086
+
1087
+ Retry-After:
1088
+ description: |
1089
+ The Retry-After header indicates how long the user agent should wait before making a follow-up request.
1090
+ The value is in seconds and can be an integer or a date in the future.
1091
+ If the value is an integer, it indicates the number of seconds to wait.
1092
+ If the value is a date, it indicates the time at which the user agent should make a follow-up request.
1093
+ schema:
1094
+ type: string
1095
+ examples:
1096
+ integer:
1097
+ value: '120'
1098
+ summary: Retry after 120 seconds
1099
+ date:
1100
+ value: 'Fri, 31 Dec 2021 23:59:59 GMT'
1101
+ summary: Retry after the specified date
1102
+ responses:
1103
+ BadRequest:
1104
+ description: Bad Request
1105
+ headers:
1106
+ RateLimit:
1107
+ $ref: '#/components/headers/RateLimit'
1108
+ content:
1109
+ application/problem+json:
1110
+ schema:
1111
+ $ref: '#/components/schemas/Problem'
1112
+ example:
1113
+ type: https://example.com/errors/bad-request
1114
+ title: Bad Request
1115
+ status: 400
1116
+ detail: The request is invalid or missing required parameters.
1117
+ application/problem+xml:
1118
+ schema:
1119
+ $ref: '#/components/schemas/Problem'
1120
+ example:
1121
+ type: https://example.com/errors/bad-request
1122
+ title: Bad Request
1123
+ status: 400
1124
+ detail: The request is invalid or missing required parameters.
1125
+
1126
+ Conflict:
1127
+ description: Conflict
1128
+ headers:
1129
+ RateLimit:
1130
+ $ref: '#/components/headers/RateLimit'
1131
+ content:
1132
+ application/problem+json:
1133
+ schema:
1134
+ $ref: '#/components/schemas/Problem'
1135
+ example:
1136
+ type: https://example.com/errors/conflict
1137
+ title: Conflict
1138
+ status: 409
1139
+ detail: There is a conflict with an existing resource.
1140
+ application/problem+xml:
1141
+ schema:
1142
+ $ref: '#/components/schemas/Problem'
1143
+ example:
1144
+ type: https://example.com/errors/conflict
1145
+ title: Conflict
1146
+ status: 409
1147
+ detail: There is a conflict with an existing resource.
1148
+
1149
+ Forbidden:
1150
+ description: Forbidden
1151
+ headers:
1152
+ RateLimit:
1153
+ $ref: '#/components/headers/RateLimit'
1154
+ content:
1155
+ application/problem+json:
1156
+ schema:
1157
+ $ref: '#/components/schemas/Problem'
1158
+ example:
1159
+ type: https://example.com/errors/forbidden
1160
+ title: Forbidden
1161
+ status: 403
1162
+ detail: Access is forbidden with the provided credentials.
1163
+ application/problem+xml:
1164
+ schema:
1165
+ $ref: '#/components/schemas/Problem'
1166
+ example:
1167
+ type: https://example.com/errors/forbidden
1168
+ title: Forbidden
1169
+ status: 403
1170
+ detail: Access is forbidden with the provided credentials.
1171
+
1172
+ InternalServerError:
1173
+ description: Internal Server Error
1174
+ headers:
1175
+ RateLimit:
1176
+ $ref: '#/components/headers/RateLimit'
1177
+ content:
1178
+ application/problem+json:
1179
+ schema:
1180
+ $ref: '#/components/schemas/Problem'
1181
+ example:
1182
+ type: https://example.com/errors/internal-server-error
1183
+ title: Internal Server Error
1184
+ status: 500
1185
+ detail: An unexpected error occurred.
1186
+ application/problem+xml:
1187
+ schema:
1188
+ $ref: '#/components/schemas/Problem'
1189
+ example:
1190
+ type: https://example.com/errors/internal-server-error
1191
+ title: Internal Server Error
1192
+ status: 500
1193
+ detail: An unexpected error occurred.
1194
+
1195
+ NotFound:
1196
+ description: Not Found
1197
+ headers:
1198
+ RateLimit:
1199
+ $ref: '#/components/headers/RateLimit'
1200
+ content:
1201
+ application/problem+json:
1202
+ schema:
1203
+ $ref: '#/components/schemas/Problem'
1204
+ example:
1205
+ type: https://example.com/errors/not-found
1206
+ title: Not Found
1207
+ status: 404
1208
+ detail: The requested resource was not found.
1209
+ application/problem+xml:
1210
+ schema:
1211
+ $ref: '#/components/schemas/Problem'
1212
+ example:
1213
+ type: https://example.com/errors/not-found
1214
+ title: Not Found
1215
+ status: 404
1216
+ detail: The requested resource was not found.
1217
+
1218
+ TooManyRequests:
1219
+ description: Too Many Requests
1220
+ headers:
1221
+ RateLimit:
1222
+ $ref: '#/components/headers/RateLimit'
1223
+ Retry-After:
1224
+ $ref: '#/components/headers/Retry-After'
1225
+ content:
1226
+ application/problem+json:
1227
+ schema:
1228
+ $ref: '#/components/schemas/Problem'
1229
+ example:
1230
+ type: https://example.com/errors/too-many-requests
1231
+ title: Too Many Requests
1232
+ status: 429
1233
+ detail: You have exceeded the rate limit.
1234
+ application/problem+xml:
1235
+ schema:
1236
+ $ref: '#/components/schemas/Problem'
1237
+ example:
1238
+ type: https://example.com/errors/too-many-requests
1239
+ title: Too Many Requests
1240
+ status: 429
1241
+ detail: You have exceeded the rate limit.
1242
+
1243
+ Unauthorized:
1244
+ description: Unauthorized
1245
+ headers:
1246
+ RateLimit:
1247
+ $ref: '#/components/headers/RateLimit'
1248
+ content:
1249
+ application/problem+json:
1250
+ schema:
1251
+ $ref: '#/components/schemas/Problem'
1252
+ example:
1253
+ type: https://example.com/errors/unauthorized
1254
+ title: Unauthorized
1255
+ status: 401
1256
+ detail: You do not have the necessary permissions.
1257
+ application/problem+xml:
1258
+ schema:
1259
+ $ref: '#/components/schemas/Problem'
1260
+ example:
1261
+ type: https://example.com/errors/unauthorized
1262
+ title: Unauthorized
1263
+ status: 401
1264
+ detail: You do not have the necessary permissions.