@platformatic/service 0.17.1 → 0.19.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 (57) hide show
  1. package/fixtures/hello/platformatic.service.json +3 -0
  2. package/fixtures/hello-client/hello/hello.cjs +21 -0
  3. package/fixtures/hello-client/hello/hello.d.ts +34 -0
  4. package/fixtures/hello-client/hello/hello.openapi.json +22 -0
  5. package/fixtures/hello-client/hello/package.json +5 -0
  6. package/fixtures/hello-client/platformatic.service.json +17 -0
  7. package/fixtures/hello-client/plugin.js +8 -0
  8. package/fixtures/hello-client-ts/dist/plugin.js +21 -0
  9. package/fixtures/hello-client-ts/dist/plugin.js.map +1 -0
  10. package/fixtures/hello-client-ts/hello/hello.cjs +21 -0
  11. package/fixtures/hello-client-ts/hello/hello.d.ts +34 -0
  12. package/fixtures/hello-client-ts/hello/hello.openapi.json +22 -0
  13. package/fixtures/hello-client-ts/hello/package.json +5 -0
  14. package/fixtures/hello-client-ts/platformatic.service.json +18 -0
  15. package/fixtures/hello-client-ts/plugin.ts +8 -0
  16. package/fixtures/hello-client-ts/tsconfig.json +22 -0
  17. package/help/schema.txt +1 -1
  18. package/index.d.ts +18 -0
  19. package/index.js +57 -2
  20. package/index.test-d.ts +27 -0
  21. package/lib/compile.js +2 -2
  22. package/lib/config.js +0 -22
  23. package/lib/graphql.js +21 -0
  24. package/lib/load-config.js +6 -1
  25. package/lib/openapi-schema-defs.js +1140 -0
  26. package/lib/openapi.js +42 -0
  27. package/lib/schema.js +334 -27
  28. package/lib/utils.js +12 -1
  29. package/package.json +16 -6
  30. package/service.mjs +0 -0
  31. package/test/cli/compile.test.mjs +55 -33
  32. package/test/cli/gen-schema.test.mjs +1 -2
  33. package/test/cli/watch.test.mjs +13 -6
  34. package/test/clients.test.js +59 -0
  35. package/test/config.test.js +2 -1
  36. package/test/fixtures/bad-typescript-plugin/dist/tsconfig.tsbuildinfo +1 -1
  37. package/test/fixtures/hello-world-resolver.js +16 -0
  38. package/test/fixtures/typescript-autoload/platformatic.service.json +13 -0
  39. package/test/fixtures/typescript-autoload/routes/plugin.ts +5 -0
  40. package/test/fixtures/typescript-autoload/tsconfig.json +22 -0
  41. package/test/graphql.test.js +154 -0
  42. package/test/helper.js +1 -2
  43. package/test/https.test.js +58 -0
  44. package/test/routes.test.js +123 -5
  45. package/test/tmp/typescript-plugin-clone-3/dist/tsconfig.tsbuildinfo +1 -1
  46. package/test/tmp/typescript-plugin-clone-4/dist/tsconfig.tsbuildinfo +1 -1
  47. package/test/tmp/typescript-plugin-clone-7/inner-folder/dist/plugin.js +18 -0
  48. package/test/tmp/typescript-plugin-clone-7/inner-folder/dist/plugin.js.map +1 -0
  49. package/test/tmp/typescript-plugin-clone-7/inner-folder/platformatic.service.json +13 -0
  50. package/test/tmp/typescript-plugin-clone-7/inner-folder/plugin.ts +5 -0
  51. package/test/tmp/typescript-plugin-clone-7/inner-folder/tsconfig.json +22 -0
  52. package/test/tmp/typescript-plugin-clone-8/dist/routes/plugin.js +7 -0
  53. package/test/tmp/typescript-plugin-clone-8/dist/routes/plugin.js.map +1 -0
  54. package/test/tmp/typescript-plugin-clone-8/dist/tsconfig.tsbuildinfo +1 -0
  55. package/test/tmp/typescript-plugin-clone-8/platformatic.service.json +13 -0
  56. package/test/tmp/typescript-plugin-clone-8/routes/plugin.ts +5 -0
  57. package/test/tmp/typescript-plugin-clone-8/tsconfig.json +22 -0
@@ -0,0 +1,1140 @@
1
+ 'use strict'
2
+
3
+ const $defs = {
4
+ info: {
5
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#info-object',
6
+ type: 'object',
7
+ properties: {
8
+ title: {
9
+ type: 'string'
10
+ },
11
+ summary: {
12
+ type: 'string'
13
+ },
14
+ description: {
15
+ type: 'string'
16
+ },
17
+ termsOfService: {
18
+ type: 'string'
19
+ },
20
+ contact: {
21
+ $ref: '#/$defs/contact'
22
+ },
23
+ license: {
24
+ $ref: '#/$defs/license'
25
+ },
26
+ version: {
27
+ type: 'string'
28
+ }
29
+ },
30
+ required: [
31
+ 'title',
32
+ 'version'
33
+ ],
34
+ $ref: '#/$defs/specification-extensions'
35
+ },
36
+ contact: {
37
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#contact-object',
38
+ type: 'object',
39
+ properties: {
40
+ name: {
41
+ type: 'string'
42
+ },
43
+ url: {
44
+ type: 'string'
45
+ },
46
+ email: {
47
+ type: 'string'
48
+ }
49
+ },
50
+ $ref: '#/$defs/specification-extensions'
51
+ },
52
+ license: {
53
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#license-object',
54
+ type: 'object',
55
+ properties: {
56
+ name: {
57
+ type: 'string'
58
+ },
59
+ identifier: {
60
+ type: 'string'
61
+ },
62
+ url: {
63
+ type: 'string'
64
+ }
65
+ },
66
+ required: [
67
+ 'name'
68
+ ],
69
+ $ref: '#/$defs/specification-extensions'
70
+ },
71
+ server: {
72
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#server-object',
73
+ type: 'object',
74
+ properties: {
75
+ url: {
76
+ type: 'string'
77
+ },
78
+ description: {
79
+ type: 'string'
80
+ },
81
+ variables: {
82
+ type: 'object',
83
+ additionalProperties: {
84
+ $ref: '#/$defs/server-variable'
85
+ }
86
+ }
87
+ },
88
+ required: [
89
+ 'url'
90
+ ],
91
+ $ref: '#/$defs/specification-extensions'
92
+ },
93
+ 'server-variable': {
94
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#server-variable-object',
95
+ type: 'object',
96
+ properties: {
97
+ enum: {
98
+ type: 'array',
99
+ items: {
100
+ type: 'string'
101
+ },
102
+ minItems: 1
103
+ },
104
+ default: {
105
+ type: 'string'
106
+ },
107
+ description: {
108
+ type: 'string'
109
+ }
110
+ },
111
+ required: [
112
+ 'default'
113
+ ],
114
+ $ref: '#/$defs/specification-extensions'
115
+ },
116
+ components: {
117
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#components-object',
118
+ type: 'object',
119
+ properties: {
120
+ schemas: {
121
+ type: 'object'
122
+ },
123
+ responses: {
124
+ type: 'object',
125
+ additionalProperties: {
126
+ $ref: '#/$defs/response-or-reference'
127
+ }
128
+ },
129
+ parameters: {
130
+ type: 'object',
131
+ additionalProperties: {
132
+ $ref: '#/$defs/parameter-or-reference'
133
+ }
134
+ },
135
+ examples: {
136
+ type: 'object',
137
+ additionalProperties: {
138
+ $ref: '#/$defs/example-or-reference'
139
+ }
140
+ },
141
+ requestBodies: {
142
+ type: 'object',
143
+ additionalProperties: {
144
+ $ref: '#/$defs/request-body-or-reference'
145
+ }
146
+ },
147
+ headers: {
148
+ type: 'object',
149
+ additionalProperties: {
150
+ $ref: '#/$defs/header-or-reference'
151
+ }
152
+ },
153
+ securitySchemes: {
154
+ type: 'object',
155
+ additionalProperties: {
156
+ $ref: '#/$defs/security-scheme-or-reference'
157
+ }
158
+ },
159
+ links: {
160
+ type: 'object',
161
+ additionalProperties: {
162
+ $ref: '#/$defs/link-or-reference'
163
+ }
164
+ },
165
+ callbacks: {
166
+ type: 'object',
167
+ additionalProperties: {
168
+ $ref: '#/$defs/callbacks-or-reference'
169
+ }
170
+ },
171
+ pathItems: {
172
+ type: 'object',
173
+ additionalProperties: {
174
+ $ref: '#/$defs/path-item-or-reference'
175
+ }
176
+ }
177
+ },
178
+ $ref: '#/$defs/specification-extensions'
179
+ },
180
+ paths: {
181
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#paths-object',
182
+ type: 'object',
183
+ patternProperties: {
184
+ '^/': {
185
+ $ref: '#/$defs/path-item'
186
+ }
187
+ },
188
+ $ref: '#/$defs/specification-extensions'
189
+ },
190
+ 'path-item': {
191
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#path-item-object',
192
+ type: 'object',
193
+ properties: {
194
+ summary: {
195
+ type: 'string'
196
+ },
197
+ description: {
198
+ type: 'string'
199
+ },
200
+ servers: {
201
+ type: 'array',
202
+ items: {
203
+ $ref: '#/$defs/server'
204
+ }
205
+ },
206
+ parameters: {
207
+ type: 'array',
208
+ items: {
209
+ $ref: '#/$defs/parameter-or-reference'
210
+ }
211
+ },
212
+ get: {
213
+ $ref: '#/$defs/operation'
214
+ },
215
+ put: {
216
+ $ref: '#/$defs/operation'
217
+ },
218
+ post: {
219
+ $ref: '#/$defs/operation'
220
+ },
221
+ delete: {
222
+ $ref: '#/$defs/operation'
223
+ },
224
+ options: {
225
+ $ref: '#/$defs/operation'
226
+ },
227
+ head: {
228
+ $ref: '#/$defs/operation'
229
+ },
230
+ patch: {
231
+ $ref: '#/$defs/operation'
232
+ },
233
+ trace: {
234
+ $ref: '#/$defs/operation'
235
+ }
236
+ },
237
+ $ref: '#/$defs/specification-extensions'
238
+ },
239
+ 'path-item-or-reference': {
240
+ if: {
241
+ type: 'object',
242
+ required: [
243
+ '$ref'
244
+ ]
245
+ },
246
+ then: {
247
+ $ref: '#/$defs/reference'
248
+ },
249
+ else: {
250
+ $ref: '#/$defs/path-item'
251
+ }
252
+ },
253
+ operation: {
254
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#operation-object',
255
+ type: 'object',
256
+ properties: {
257
+ tags: {
258
+ type: 'array',
259
+ items: {
260
+ type: 'string'
261
+ }
262
+ },
263
+ summary: {
264
+ type: 'string'
265
+ },
266
+ description: {
267
+ type: 'string'
268
+ },
269
+ externalDocs: {
270
+ $ref: '#/$defs/external-documentation'
271
+ },
272
+ operationId: {
273
+ type: 'string'
274
+ },
275
+ parameters: {
276
+ type: 'array',
277
+ items: {
278
+ $ref: '#/$defs/parameter-or-reference'
279
+ }
280
+ },
281
+ requestBody: {
282
+ $ref: '#/$defs/request-body-or-reference'
283
+ },
284
+ responses: {
285
+ $ref: '#/$defs/responses'
286
+ },
287
+ callbacks: {
288
+ type: 'object',
289
+ additionalProperties: {
290
+ $ref: '#/$defs/callbacks-or-reference'
291
+ }
292
+ },
293
+ deprecated: {
294
+ default: false,
295
+ type: 'boolean'
296
+ },
297
+ security: {
298
+ type: 'array',
299
+ items: {
300
+ $ref: '#/$defs/security-requirement'
301
+ }
302
+ },
303
+ servers: {
304
+ type: 'array',
305
+ items: {
306
+ $ref: '#/$defs/server'
307
+ }
308
+ }
309
+ },
310
+ $ref: '#/$defs/specification-extensions'
311
+ },
312
+ 'external-documentation': {
313
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#external-documentation-object',
314
+ type: 'object',
315
+ properties: {
316
+ description: {
317
+ type: 'string'
318
+ },
319
+ url: {
320
+ type: 'string'
321
+ }
322
+ },
323
+ required: [
324
+ 'url'
325
+ ],
326
+ $ref: '#/$defs/specification-extensions'
327
+ },
328
+ parameter: {
329
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#parameter-object',
330
+ type: 'object',
331
+ properties: {
332
+ name: {
333
+ type: 'string'
334
+ },
335
+ in: {
336
+ enum: [
337
+ 'query',
338
+ 'header',
339
+ 'path',
340
+ 'cookie'
341
+ ]
342
+ },
343
+ description: {
344
+ type: 'string'
345
+ },
346
+ required: {
347
+ default: false,
348
+ type: 'boolean'
349
+ },
350
+ deprecated: {
351
+ default: false,
352
+ type: 'boolean'
353
+ },
354
+ content: {
355
+ type: 'object',
356
+ $ref: '#/$defs/content',
357
+ minProperties: 1,
358
+ maxProperties: 1
359
+ }
360
+ },
361
+ required: [
362
+ 'name',
363
+ 'in'
364
+ ],
365
+ oneOf: [
366
+ {
367
+ required: [
368
+ 'schema'
369
+ ]
370
+ },
371
+ {
372
+ required: [
373
+ 'content'
374
+ ]
375
+ }
376
+ ],
377
+ if: {
378
+ type: 'object',
379
+ properties: {
380
+ in: {
381
+ const: 'query'
382
+ }
383
+ },
384
+ required: [
385
+ 'in'
386
+ ]
387
+ },
388
+ then: {
389
+ type: 'object',
390
+ properties: {
391
+ allowEmptyValue: {
392
+ default: false,
393
+ type: 'boolean'
394
+ }
395
+ }
396
+ },
397
+ $ref: '#/$defs/specification-extensions'
398
+ },
399
+ 'parameter-or-reference': {
400
+ if: {
401
+ type: 'object',
402
+ required: [
403
+ '$ref'
404
+ ]
405
+ },
406
+ then: {
407
+ $ref: '#/$defs/reference'
408
+ },
409
+ else: {
410
+ $ref: '#/$defs/parameter'
411
+ }
412
+ },
413
+ 'request-body': {
414
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#request-body-object',
415
+ type: 'object',
416
+ properties: {
417
+ description: {
418
+ type: 'string'
419
+ },
420
+ content: {
421
+ $ref: '#/$defs/content'
422
+ },
423
+ required: {
424
+ default: false,
425
+ type: 'boolean'
426
+ }
427
+ },
428
+ required: [
429
+ 'content'
430
+ ],
431
+ $ref: '#/$defs/specification-extensions'
432
+ },
433
+ 'request-body-or-reference': {
434
+ if: {
435
+ type: 'object',
436
+ required: [
437
+ '$ref'
438
+ ]
439
+ },
440
+ then: {
441
+ $ref: '#/$defs/reference'
442
+ },
443
+ else: {
444
+ $ref: '#/$defs/request-body'
445
+ }
446
+ },
447
+ content: {
448
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#fixed-fields-10',
449
+ type: 'object',
450
+ additionalProperties: {
451
+ $ref: '#/$defs/media-type'
452
+ }
453
+ },
454
+ 'media-type': {
455
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#media-type-object',
456
+ type: 'object',
457
+ properties: {
458
+ encoding: {
459
+ type: 'object',
460
+ additionalProperties: {
461
+ $ref: '#/$defs/encoding'
462
+ }
463
+ }
464
+ },
465
+ allOf: [
466
+ {
467
+ $ref: '#/$defs/specification-extensions'
468
+ },
469
+ {
470
+ $ref: '#/$defs/examples'
471
+ }
472
+ ]
473
+ },
474
+ encoding: {
475
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#encoding-object',
476
+ type: 'object',
477
+ properties: {
478
+ contentType: {
479
+ type: 'string'
480
+ },
481
+ headers: {
482
+ type: 'object',
483
+ additionalProperties: {
484
+ $ref: '#/$defs/header-or-reference'
485
+ }
486
+ },
487
+ style: {
488
+ default: 'form',
489
+ enum: [
490
+ 'form',
491
+ 'spaceDelimited',
492
+ 'pipeDelimited',
493
+ 'deepObject'
494
+ ]
495
+ },
496
+ explode: {
497
+ type: 'boolean'
498
+ },
499
+ allowReserved: {
500
+ default: false,
501
+ type: 'boolean'
502
+ }
503
+ },
504
+ allOf: [
505
+ {
506
+ $ref: '#/$defs/specification-extensions'
507
+ },
508
+ {
509
+ $ref: '#/$defs/encoding/$defs/explode-default'
510
+ }
511
+ ],
512
+
513
+ $defs: {
514
+ 'explode-default': {
515
+ if: {
516
+ type: 'object',
517
+ properties: {
518
+ style: {
519
+ const: 'form'
520
+ }
521
+ },
522
+ required: [
523
+ 'style'
524
+ ]
525
+ },
526
+ then: {
527
+ type: 'object',
528
+ properties: {
529
+ explode: {
530
+ default: true
531
+ }
532
+ }
533
+ },
534
+ else: {
535
+ type: 'object',
536
+ properties: {
537
+ explode: {
538
+ default: false
539
+ }
540
+ }
541
+ }
542
+ }
543
+ }
544
+ },
545
+ responses: {
546
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#responses-object',
547
+ type: 'object',
548
+ properties: {
549
+ default: {
550
+ $ref: '#/$defs/response-or-reference'
551
+ }
552
+ },
553
+ patternProperties: {
554
+ '^[1-5](?:[0-9]{2}|XX)$': {
555
+ $ref: '#/$defs/response-or-reference'
556
+ }
557
+ },
558
+ minProperties: 1,
559
+ $ref: '#/$defs/specification-extensions',
560
+
561
+ if: {
562
+ $comment: 'either default, or at least one response code property must exist',
563
+ type: 'object',
564
+ patternProperties: {
565
+ '^[1-5](?:[0-9]{2}|XX)$': false
566
+ }
567
+ },
568
+ then: {
569
+ required: [
570
+ 'default'
571
+ ]
572
+ }
573
+ },
574
+ response: {
575
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#response-object',
576
+ type: 'object',
577
+ properties: {
578
+ description: {
579
+ type: 'string'
580
+ },
581
+ headers: {
582
+ type: 'object',
583
+ additionalProperties: {
584
+ $ref: '#/$defs/header-or-reference'
585
+ }
586
+ },
587
+ content: {
588
+ $ref: '#/$defs/content'
589
+ },
590
+ links: {
591
+ type: 'object',
592
+ additionalProperties: {
593
+ $ref: '#/$defs/link-or-reference'
594
+ }
595
+ }
596
+ },
597
+ required: [
598
+ 'description'
599
+ ],
600
+ $ref: '#/$defs/specification-extensions'
601
+ },
602
+ 'response-or-reference': {
603
+ if: {
604
+ type: 'object',
605
+ required: [
606
+ '$ref'
607
+ ]
608
+ },
609
+ then: {
610
+ $ref: '#/$defs/reference'
611
+ },
612
+ else: {
613
+ $ref: '#/$defs/response'
614
+ }
615
+ },
616
+ callbacks: {
617
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#callback-object',
618
+ type: 'object',
619
+ $ref: '#/$defs/specification-extensions',
620
+ additionalProperties: {
621
+ $ref: '#/$defs/path-item-or-reference'
622
+ }
623
+ },
624
+ 'callbacks-or-reference': {
625
+ if: {
626
+ type: 'object',
627
+ required: [
628
+ '$ref'
629
+ ]
630
+ },
631
+ then: {
632
+ $ref: '#/$defs/reference'
633
+ },
634
+ else: {
635
+ $ref: '#/$defs/callbacks'
636
+ }
637
+ },
638
+ example: {
639
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#example-object',
640
+ type: 'object',
641
+ properties: {
642
+ summary: {
643
+ type: 'string'
644
+ },
645
+ description: {
646
+ type: 'string'
647
+ },
648
+ value: true,
649
+ externalValue: {
650
+ type: 'string'
651
+ }
652
+ },
653
+ not: {
654
+ required: [
655
+ 'value',
656
+ 'externalValue'
657
+ ]
658
+ },
659
+ $ref: '#/$defs/specification-extensions'
660
+ },
661
+ 'example-or-reference': {
662
+ if: {
663
+ type: 'object',
664
+ required: [
665
+ '$ref'
666
+ ]
667
+ },
668
+ then: {
669
+ $ref: '#/$defs/reference'
670
+ },
671
+ else: {
672
+ $ref: '#/$defs/example'
673
+ }
674
+ },
675
+ link: {
676
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#link-object',
677
+ type: 'object',
678
+ properties: {
679
+ operationRef: {
680
+ type: 'string'
681
+ },
682
+ operationId: {
683
+ type: 'string'
684
+ },
685
+ parameters: {
686
+ $ref: '#/$defs/map-of-strings'
687
+ },
688
+ requestBody: true,
689
+ description: {
690
+ type: 'string'
691
+ },
692
+ body: {
693
+ $ref: '#/$defs/server'
694
+ }
695
+ },
696
+ oneOf: [
697
+ {
698
+ required: [
699
+ 'operationRef'
700
+ ]
701
+ },
702
+ {
703
+ required: [
704
+ 'operationId'
705
+ ]
706
+ }
707
+ ],
708
+ $ref: '#/$defs/specification-extensions'
709
+ },
710
+ 'link-or-reference': {
711
+ if: {
712
+ type: 'object',
713
+ required: [
714
+ '$ref'
715
+ ]
716
+ },
717
+ then: {
718
+ $ref: '#/$defs/reference'
719
+ },
720
+ else: {
721
+ $ref: '#/$defs/link'
722
+ }
723
+ },
724
+ header: {
725
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#header-object',
726
+ type: 'object',
727
+ properties: {
728
+ description: {
729
+ type: 'string'
730
+ },
731
+ required: {
732
+ default: false,
733
+ type: 'boolean'
734
+ },
735
+ deprecated: {
736
+ default: false,
737
+ type: 'boolean'
738
+ },
739
+ content: {
740
+ type: 'object',
741
+ $ref: '#/$defs/content',
742
+ minProperties: 1,
743
+ maxProperties: 1
744
+ }
745
+ },
746
+ oneOf: [
747
+ {
748
+ required: [
749
+ 'schema'
750
+ ]
751
+ },
752
+ {
753
+ required: [
754
+ 'content'
755
+ ]
756
+ }
757
+ ],
758
+ $ref: '#/$defs/specification-extensions'
759
+ },
760
+ 'header-or-reference': {
761
+ if: {
762
+ type: 'object',
763
+ required: [
764
+ '$ref'
765
+ ]
766
+ },
767
+ then: {
768
+ $ref: '#/$defs/reference'
769
+ },
770
+ else: {
771
+ $ref: '#/$defs/header'
772
+ }
773
+ },
774
+ tag: {
775
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#tag-object',
776
+ type: 'object',
777
+ properties: {
778
+ name: {
779
+ type: 'string'
780
+ },
781
+ description: {
782
+ type: 'string'
783
+ },
784
+ externalDocs: {
785
+ $ref: '#/$defs/external-documentation'
786
+ }
787
+ },
788
+ required: [
789
+ 'name'
790
+ ],
791
+ $ref: '#/$defs/specification-extensions'
792
+ },
793
+ reference: {
794
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#reference-object',
795
+ type: 'object',
796
+ properties: {
797
+ $ref: {
798
+ type: 'string'
799
+ },
800
+ summary: {
801
+ type: 'string'
802
+ },
803
+ description: {
804
+ type: 'string'
805
+ }
806
+ }
807
+ },
808
+ schema: {
809
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#schema-object',
810
+ type: [
811
+ 'object',
812
+ 'boolean'
813
+ ]
814
+ },
815
+ 'security-scheme': {
816
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#security-scheme-object',
817
+ type: 'object',
818
+ properties: {
819
+ type: {
820
+ enum: [
821
+ 'apiKey',
822
+ 'http',
823
+ 'mutualTLS',
824
+ 'oauth2',
825
+ 'openIdConnect'
826
+ ]
827
+ },
828
+ description: {
829
+ type: 'string'
830
+ }
831
+ },
832
+ required: [
833
+ 'type'
834
+ ],
835
+ allOf: [
836
+ {
837
+ $ref: '#/$defs/specification-extensions'
838
+ },
839
+ {
840
+ $ref: '#/$defs/security-scheme/$defs/type-apikey'
841
+ },
842
+ {
843
+ $ref: '#/$defs/security-scheme/$defs/type-http'
844
+ },
845
+ {
846
+ $ref: '#/$defs/security-scheme/$defs/type-http-bearer'
847
+ },
848
+ {
849
+ $ref: '#/$defs/security-scheme/$defs/type-oauth2'
850
+ },
851
+ {
852
+ $ref: '#/$defs/security-scheme/$defs/type-oidc'
853
+ }
854
+ ],
855
+ $defs: {
856
+ 'type-apikey': {
857
+ if: {
858
+ type: 'object',
859
+ properties: {
860
+ type: {
861
+ const: 'apiKey'
862
+ }
863
+ },
864
+ required: [
865
+ 'type'
866
+ ]
867
+ },
868
+ then: {
869
+ type: 'object',
870
+ properties: {
871
+ name: {
872
+ type: 'string'
873
+ },
874
+ in: {
875
+ enum: [
876
+ 'query',
877
+ 'header',
878
+ 'cookie'
879
+ ]
880
+ }
881
+ },
882
+ required: [
883
+ 'name',
884
+ 'in'
885
+ ]
886
+ }
887
+ },
888
+ 'type-http': {
889
+ if: {
890
+ type: 'object',
891
+ properties: {
892
+ type: {
893
+ const: 'http'
894
+ }
895
+ },
896
+ required: [
897
+ 'type'
898
+ ]
899
+ },
900
+ then: {
901
+ type: 'object',
902
+ properties: {
903
+ scheme: {
904
+ type: 'string'
905
+ }
906
+ },
907
+ required: [
908
+ 'scheme'
909
+ ]
910
+ }
911
+ },
912
+ 'type-http-bearer': {
913
+ if: {
914
+ type: 'object',
915
+ properties: {
916
+ type: {
917
+ const: 'http'
918
+ },
919
+ scheme: {
920
+ type: 'string',
921
+ pattern: '^[Bb][Ee][Aa][Rr][Ee][Rr]$'
922
+ }
923
+ },
924
+ required: [
925
+ 'type',
926
+ 'scheme'
927
+ ]
928
+ },
929
+ then: {
930
+ type: 'object',
931
+ properties: {
932
+ bearerFormat: {
933
+ type: 'string'
934
+ }
935
+ }
936
+ }
937
+ },
938
+ 'type-oauth2': {
939
+ if: {
940
+ type: 'object',
941
+ properties: {
942
+ type: {
943
+ const: 'oauth2'
944
+ }
945
+ },
946
+ required: [
947
+ 'type'
948
+ ]
949
+ },
950
+ then: {
951
+ type: 'object',
952
+ properties: {
953
+ flows: {
954
+ $ref: '#/$defs/oauth-flows'
955
+ }
956
+ },
957
+ required: [
958
+ 'flows'
959
+ ]
960
+ }
961
+ },
962
+ 'type-oidc': {
963
+ if: {
964
+ type: 'object',
965
+ properties: {
966
+ type: {
967
+ const: 'openIdConnect'
968
+ }
969
+ },
970
+ required: [
971
+ 'type'
972
+ ]
973
+ },
974
+ then: {
975
+ type: 'object',
976
+ properties: {
977
+ openIdConnectUrl: {
978
+ type: 'string'
979
+ }
980
+ },
981
+ required: [
982
+ 'openIdConnectUrl'
983
+ ]
984
+ }
985
+ }
986
+ }
987
+ },
988
+ 'security-scheme-or-reference': {
989
+ if: {
990
+ type: 'object',
991
+ required: [
992
+ '$ref'
993
+ ]
994
+ },
995
+ then: {
996
+ $ref: '#/$defs/reference'
997
+ },
998
+ else: {
999
+ $ref: '#/$defs/security-scheme'
1000
+ }
1001
+ },
1002
+ 'oauth-flows': {
1003
+ type: 'object',
1004
+ properties: {
1005
+ implicit: {
1006
+ $ref: '#/$defs/oauth-flows/$defs/implicit'
1007
+ },
1008
+ password: {
1009
+ $ref: '#/$defs/oauth-flows/$defs/password'
1010
+ },
1011
+ clientCredentials: {
1012
+ $ref: '#/$defs/oauth-flows/$defs/client-credentials'
1013
+ },
1014
+ authorizationCode: {
1015
+ $ref: '#/$defs/oauth-flows/$defs/authorization-code'
1016
+ }
1017
+ },
1018
+ $ref: '#/$defs/specification-extensions',
1019
+
1020
+ $defs: {
1021
+ implicit: {
1022
+ type: 'object',
1023
+ properties: {
1024
+ authorizationUrl: {
1025
+ type: 'string'
1026
+ },
1027
+ refreshUrl: {
1028
+ type: 'string'
1029
+ },
1030
+ scopes: {
1031
+ $ref: '#/$defs/map-of-strings'
1032
+ }
1033
+ },
1034
+ required: [
1035
+ 'authorizationUrl',
1036
+ 'scopes'
1037
+ ],
1038
+ $ref: '#/$defs/specification-extensions'
1039
+ },
1040
+ password: {
1041
+ type: 'object',
1042
+ properties: {
1043
+ tokenUrl: {
1044
+ type: 'string'
1045
+ },
1046
+ refreshUrl: {
1047
+ type: 'string'
1048
+ },
1049
+ scopes: {
1050
+ $ref: '#/$defs/map-of-strings'
1051
+ }
1052
+ },
1053
+ required: [
1054
+ 'tokenUrl',
1055
+ 'scopes'
1056
+ ],
1057
+ $ref: '#/$defs/specification-extensions'
1058
+ },
1059
+ 'client-credentials': {
1060
+ type: 'object',
1061
+ properties: {
1062
+ tokenUrl: {
1063
+ type: 'string'
1064
+ },
1065
+ refreshUrl: {
1066
+ type: 'string'
1067
+ },
1068
+ scopes: {
1069
+ $ref: '#/$defs/map-of-strings'
1070
+ }
1071
+ },
1072
+ required: [
1073
+ 'tokenUrl',
1074
+ 'scopes'
1075
+ ],
1076
+ $ref: '#/$defs/specification-extensions'
1077
+ },
1078
+ 'authorization-code': {
1079
+ type: 'object',
1080
+ properties: {
1081
+ authorizationUrl: {
1082
+ type: 'string'
1083
+ },
1084
+ tokenUrl: {
1085
+ type: 'string'
1086
+ },
1087
+ refreshUrl: {
1088
+ type: 'string'
1089
+ },
1090
+ scopes: {
1091
+ $ref: '#/$defs/map-of-strings'
1092
+ }
1093
+ },
1094
+ required: [
1095
+ 'authorizationUrl',
1096
+ 'tokenUrl',
1097
+ 'scopes'
1098
+ ],
1099
+ $ref: '#/$defs/specification-extensions'
1100
+ }
1101
+ }
1102
+ },
1103
+ 'security-requirement': {
1104
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#security-requirement-object',
1105
+ type: 'object',
1106
+ additionalProperties: {
1107
+ type: 'array',
1108
+ items: {
1109
+ type: 'string'
1110
+ }
1111
+ }
1112
+ },
1113
+ 'specification-extensions': {
1114
+ $comment: 'https://spec.openapis.org/oas/v3.1.0#specification-extensions',
1115
+ type: 'object',
1116
+ patternProperties: {
1117
+ '^x-': true
1118
+ }
1119
+ },
1120
+ examples: {
1121
+ type: 'object',
1122
+ properties: {
1123
+ example: true,
1124
+ examples: {
1125
+ type: 'object',
1126
+ additionalProperties: {
1127
+ $ref: '#/$defs/example-or-reference'
1128
+ }
1129
+ }
1130
+ }
1131
+ },
1132
+ 'map-of-strings': {
1133
+ type: 'object',
1134
+ additionalProperties: {
1135
+ type: 'string'
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ module.exports = $defs