@automatons/validator 2.0.1 → 2.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.
package/index.js CHANGED
@@ -1,3008 +1,25 @@
1
1
  // src/validator.ts
2
- import JsonSchema from "@hyperjump/json-schema";
3
-
4
- // src/schemas/v3_1.json
5
- var v3_1_default = {
6
- $id: "https://spec.openapis.org/oas/3.1/schema/2021-09-28",
7
- $schema: "https://json-schema.org/draft/2020-12/schema",
8
- type: "object",
9
- properties: {
10
- openapi: {
11
- type: "string",
12
- pattern: "^3\\.1\\.\\d+(-.+)?$"
13
- },
14
- info: {
15
- $ref: "#/$defs/info"
16
- },
17
- jsonSchemaDialect: {
18
- type: "string",
19
- format: "uri",
20
- default: "https://spec.openapis.org/oas/3.1/dialect/base"
21
- },
22
- servers: {
23
- type: "array",
24
- items: {
25
- $ref: "#/$defs/server"
26
- }
27
- },
28
- paths: {
29
- $ref: "#/$defs/paths"
30
- },
31
- webhooks: {
32
- type: "object",
33
- additionalProperties: {
34
- $ref: "#/$defs/path-item-or-reference"
35
- }
36
- },
37
- components: {
38
- $ref: "#/$defs/components"
39
- },
40
- security: {
41
- type: "array",
42
- items: {
43
- $ref: "#/$defs/security-requirement"
44
- }
45
- },
46
- tags: {
47
- type: "array",
48
- items: {
49
- $ref: "#/$defs/tag"
50
- }
51
- },
52
- externalDocs: {
53
- $ref: "#/$defs/external-documentation"
54
- }
55
- },
56
- required: [
57
- "openapi",
58
- "info"
59
- ],
60
- anyOf: [
61
- {
62
- required: [
63
- "paths"
64
- ]
65
- },
66
- {
67
- required: [
68
- "components"
69
- ]
70
- },
71
- {
72
- required: [
73
- "webhooks"
74
- ]
75
- }
76
- ],
77
- $ref: "#/$defs/specification-extensions",
78
- unevaluatedProperties: false,
79
- $defs: {
80
- info: {
81
- type: "object",
82
- properties: {
83
- title: {
84
- type: "string"
85
- },
86
- summary: {
87
- type: "string"
88
- },
89
- description: {
90
- type: "string"
91
- },
92
- termsOfService: {
93
- type: "string"
94
- },
95
- contact: {
96
- $ref: "#/$defs/contact"
97
- },
98
- license: {
99
- $ref: "#/$defs/license"
100
- },
101
- version: {
102
- type: "string"
103
- }
104
- },
105
- required: [
106
- "title",
107
- "version"
108
- ],
109
- $ref: "#/$defs/specification-extensions",
110
- unevaluatedProperties: false
111
- },
112
- contact: {
113
- type: "object",
114
- properties: {
115
- name: {
116
- type: "string"
117
- },
118
- url: {
119
- type: "string"
120
- },
121
- email: {
122
- type: "string"
123
- }
124
- },
125
- $ref: "#/$defs/specification-extensions",
126
- unevaluatedProperties: false
127
- },
128
- license: {
129
- type: "object",
130
- properties: {
131
- name: {
132
- type: "string"
133
- },
134
- identifier: {
135
- type: "string"
136
- },
137
- url: {
138
- type: "string",
139
- format: "uri"
140
- }
141
- },
142
- required: [
143
- "name"
144
- ],
145
- oneOf: [
146
- {
147
- required: [
148
- "identifier"
149
- ]
150
- },
151
- {
152
- required: [
153
- "url"
154
- ]
155
- }
156
- ],
157
- $ref: "#/$defs/specification-extensions",
158
- unevaluatedProperties: false
159
- },
160
- server: {
161
- type: "object",
162
- properties: {
163
- url: {
164
- type: "string",
165
- format: "uri-reference"
166
- },
167
- description: {
168
- type: "string"
169
- },
170
- variables: {
171
- type: "object",
172
- additionalProperties: {
173
- $ref: "#/$defs/server-variable"
174
- }
175
- }
176
- },
177
- required: [
178
- "url"
179
- ],
180
- $ref: "#/$defs/specification-extensions",
181
- unevaluatedProperties: false
182
- },
183
- "server-variable": {
184
- type: "object",
185
- properties: {
186
- enum: {
187
- type: "array",
188
- items: {
189
- type: "string"
190
- },
191
- minItems: 1
192
- },
193
- default: {
194
- type: "string"
195
- },
196
- descriptions: {
197
- type: "string"
198
- }
199
- },
200
- required: [
201
- "default"
202
- ],
203
- $ref: "#/$defs/specification-extensions",
204
- unevaluatedProperties: false
205
- },
206
- components: {
207
- type: "object",
208
- properties: {
209
- schemas: {
210
- type: "object",
211
- additionalProperties: {
212
- $dynamicRef: "#meta"
213
- }
214
- },
215
- responses: {
216
- type: "object",
217
- additionalProperties: {
218
- $ref: "#/$defs/response-or-reference"
219
- }
220
- },
221
- parameters: {
222
- type: "object",
223
- additionalProperties: {
224
- $ref: "#/$defs/parameter-or-reference"
225
- }
226
- },
227
- examples: {
228
- type: "object",
229
- additionalProperties: {
230
- $ref: "#/$defs/example-or-reference"
231
- }
232
- },
233
- requestBodies: {
234
- type: "object",
235
- additionalProperties: {
236
- $ref: "#/$defs/request-body-or-reference"
237
- }
238
- },
239
- headers: {
240
- type: "object",
241
- additionalProperties: {
242
- $ref: "#/$defs/header-or-reference"
243
- }
244
- },
245
- securitySchemes: {
246
- type: "object",
247
- additionalProperties: {
248
- $ref: "#/$defs/security-scheme-or-reference"
249
- }
250
- },
251
- links: {
252
- type: "object",
253
- additionalProperties: {
254
- $ref: "#/$defs/link-or-reference"
255
- }
256
- },
257
- callbacks: {
258
- type: "object",
259
- additionalProperties: {
260
- $ref: "#/$defs/callbacks-or-reference"
261
- }
262
- },
263
- pathItems: {
264
- type: "object",
265
- additionalProperties: {
266
- $ref: "#/$defs/path-item-or-reference"
267
- }
268
- }
269
- },
270
- patternProperties: {
271
- "^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$": {
272
- $comment: "Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected",
273
- propertyNames: {
274
- pattern: "^[a-zA-Z0-9._-]+$"
275
- }
276
- }
277
- },
278
- $ref: "#/$defs/specification-extensions",
279
- unevaluatedProperties: false
280
- },
281
- paths: {
282
- type: "object",
283
- patternProperties: {
284
- "^/": {
285
- $ref: "#/$defs/path-item"
286
- }
287
- },
288
- $ref: "#/$defs/specification-extensions",
289
- unevaluatedProperties: false
290
- },
291
- "path-item": {
292
- type: "object",
293
- properties: {
294
- summary: {
295
- type: "string"
296
- },
297
- description: {
298
- type: "string"
299
- },
300
- servers: {
301
- type: "array",
302
- items: {
303
- $ref: "#/$defs/server"
304
- }
305
- },
306
- parameters: {
307
- type: "array",
308
- items: {
309
- $ref: "#/$defs/parameter-or-reference"
310
- }
311
- }
312
- },
313
- patternProperties: {
314
- "^(get|put|post|delete|options|head|patch|trace)$": {
315
- $ref: "#/$defs/operation"
316
- }
317
- },
318
- $ref: "#/$defs/specification-extensions",
319
- unevaluatedProperties: false
320
- },
321
- "path-item-or-reference": {
322
- if: {
323
- type: "object",
324
- required: [
325
- "$ref"
326
- ]
327
- },
328
- then: {
329
- $ref: "#/$defs/reference"
330
- },
331
- else: {
332
- $ref: "#/$defs/path-item"
333
- }
334
- },
335
- operation: {
336
- type: "object",
337
- properties: {
338
- tags: {
339
- type: "array",
340
- items: {
341
- type: "string"
342
- }
343
- },
344
- summary: {
345
- type: "string"
346
- },
347
- description: {
348
- type: "string"
349
- },
350
- externalDocs: {
351
- $ref: "#/$defs/external-documentation"
352
- },
353
- operationId: {
354
- type: "string"
355
- },
356
- parameters: {
357
- type: "array",
358
- items: {
359
- $ref: "#/$defs/parameter-or-reference"
360
- }
361
- },
362
- requestBody: {
363
- $ref: "#/$defs/request-body-or-reference"
364
- },
365
- responses: {
366
- $ref: "#/$defs/responses"
367
- },
368
- callbacks: {
369
- type: "object",
370
- additionalProperties: {
371
- $ref: "#/$defs/callbacks-or-reference"
372
- }
373
- },
374
- deprecated: {
375
- default: false,
376
- type: "boolean"
377
- },
378
- security: {
379
- type: "array",
380
- items: {
381
- $ref: "#/$defs/security-requirement"
382
- }
383
- },
384
- servers: {
385
- type: "array",
386
- items: {
387
- $ref: "#/$defs/server"
388
- }
389
- }
390
- },
391
- $ref: "#/$defs/specification-extensions",
392
- unevaluatedProperties: false
393
- },
394
- "external-documentation": {
395
- type: "object",
396
- properties: {
397
- description: {
398
- type: "string"
399
- },
400
- url: {
401
- type: "string",
402
- format: "uri"
403
- }
404
- },
405
- required: [
406
- "url"
407
- ],
408
- $ref: "#/$defs/specification-extensions",
409
- unevaluatedProperties: false
410
- },
411
- parameter: {
412
- type: "object",
413
- properties: {
414
- name: {
415
- type: "string"
416
- },
417
- in: {
418
- enum: [
419
- "query",
420
- "header",
421
- "path",
422
- "cookie"
423
- ]
424
- },
425
- description: {
426
- type: "string"
427
- },
428
- required: {
429
- default: false,
430
- type: "boolean"
431
- },
432
- deprecated: {
433
- default: false,
434
- type: "boolean"
435
- },
436
- allowEmptyValue: {
437
- default: false,
438
- type: "boolean"
439
- },
440
- schema: {
441
- $dynamicRef: "#meta"
442
- },
443
- content: {
444
- $ref: "#/$defs/content"
445
- }
446
- },
447
- required: [
448
- "in"
449
- ],
450
- oneOf: [
451
- {
452
- required: [
453
- "schema"
454
- ]
455
- },
456
- {
457
- required: [
458
- "content"
459
- ]
460
- }
461
- ],
462
- dependentSchemas: {
463
- schema: {
464
- properties: {
465
- style: {
466
- type: "string"
467
- },
468
- explode: {
469
- type: "boolean"
470
- },
471
- allowReserved: {
472
- default: false,
473
- type: "boolean"
474
- }
475
- },
476
- allOf: [
477
- {
478
- $ref: "#/$defs/examples"
479
- },
480
- {
481
- $ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path"
482
- },
483
- {
484
- $ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header"
485
- },
486
- {
487
- $ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query"
488
- },
489
- {
490
- $ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie"
491
- },
492
- {
493
- $ref: "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-form"
494
- }
495
- ],
496
- $defs: {
497
- "styles-for-path": {
498
- if: {
499
- properties: {
500
- in: {
501
- const: "path"
502
- }
503
- },
504
- required: [
505
- "in"
506
- ]
507
- },
508
- then: {
509
- properties: {
510
- name: {
511
- pattern: "[^/#?]+$"
512
- },
513
- style: {
514
- default: "simple",
515
- enum: [
516
- "matrix",
517
- "label",
518
- "simple"
519
- ]
520
- },
521
- required: {
522
- const: true
523
- }
524
- },
525
- required: [
526
- "required"
527
- ]
528
- }
529
- },
530
- "styles-for-header": {
531
- if: {
532
- properties: {
533
- in: {
534
- const: "header"
535
- }
536
- },
537
- required: [
538
- "in"
539
- ]
540
- },
541
- then: {
542
- properties: {
543
- style: {
544
- default: "simple",
545
- const: "simple"
546
- }
547
- }
548
- }
549
- },
550
- "styles-for-query": {
551
- if: {
552
- properties: {
553
- in: {
554
- const: "query"
555
- }
556
- },
557
- required: [
558
- "in"
559
- ]
560
- },
561
- then: {
562
- properties: {
563
- style: {
564
- default: "form",
565
- enum: [
566
- "form",
567
- "spaceDelimited",
568
- "pipeDelimited",
569
- "deepObject"
570
- ]
571
- }
572
- }
573
- }
574
- },
575
- "styles-for-cookie": {
576
- if: {
577
- properties: {
578
- in: {
579
- const: "cookie"
580
- }
581
- },
582
- required: [
583
- "in"
584
- ]
585
- },
586
- then: {
587
- properties: {
588
- style: {
589
- default: "form",
590
- const: "form"
591
- }
592
- }
593
- }
594
- },
595
- "styles-for-form": {
596
- if: {
597
- properties: {
598
- style: {
599
- const: "form"
600
- }
601
- },
602
- required: [
603
- "style"
604
- ]
605
- },
606
- then: {
607
- properties: {
608
- explode: {
609
- default: true
610
- }
611
- }
612
- },
613
- else: {
614
- properties: {
615
- explode: {
616
- default: false
617
- }
618
- }
619
- }
620
- }
621
- }
622
- }
623
- },
624
- $ref: "#/$defs/specification-extensions",
625
- unevaluatedProperties: false
626
- },
627
- "parameter-or-reference": {
628
- if: {
629
- type: "object",
630
- required: [
631
- "$ref"
632
- ]
633
- },
634
- then: {
635
- $ref: "#/$defs/reference"
636
- },
637
- else: {
638
- $ref: "#/$defs/parameter"
639
- }
640
- },
641
- "request-body": {
642
- type: "object",
643
- properties: {
644
- description: {
645
- type: "string"
646
- },
647
- content: {
648
- $ref: "#/$defs/content"
649
- },
650
- required: {
651
- default: false,
652
- type: "boolean"
653
- }
654
- },
655
- required: [
656
- "content"
657
- ],
658
- $ref: "#/$defs/specification-extensions",
659
- unevaluatedProperties: false
660
- },
661
- "request-body-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/request-body"
673
- }
674
- },
675
- content: {
676
- type: "object",
677
- additionalProperties: {
678
- $ref: "#/$defs/media-type"
679
- },
680
- propertyNames: {
681
- type: "string"
682
- }
683
- },
684
- "media-type": {
685
- type: "object",
686
- properties: {
687
- schema: {
688
- $dynamicRef: "#meta"
689
- },
690
- encoding: {
691
- type: "object",
692
- additionalProperties: {
693
- $ref: "#/$defs/encoding"
694
- }
695
- }
696
- },
697
- allOf: [
698
- {
699
- $ref: "#/$defs/specification-extensions"
700
- },
701
- {
702
- $ref: "#/$defs/examples"
703
- }
704
- ],
705
- unevaluatedProperties: false
706
- },
707
- encoding: {
708
- type: "object",
709
- properties: {
710
- contentType: {
711
- type: "string"
712
- },
713
- headers: {
714
- type: "object",
715
- additionalProperties: {
716
- $ref: "#/$defs/header-or-reference"
717
- }
718
- },
719
- style: {
720
- default: "form",
721
- enum: [
722
- "form",
723
- "spaceDelimited",
724
- "pipeDelimited",
725
- "deepObject"
726
- ]
727
- },
728
- explode: {
729
- type: "boolean"
730
- },
731
- allowReserved: {
732
- default: false,
733
- type: "boolean"
734
- }
735
- },
736
- allOf: [
737
- {
738
- $ref: "#/$defs/specification-extensions"
739
- },
740
- {
741
- $ref: "#/$defs/encoding/$defs/explode-default"
742
- }
743
- ],
744
- unevaluatedProperties: false,
745
- $defs: {
746
- "explode-default": {
747
- if: {
748
- properties: {
749
- style: {
750
- const: "form"
751
- }
752
- },
753
- required: [
754
- "style"
755
- ]
756
- },
757
- then: {
758
- properties: {
759
- explode: {
760
- default: true
761
- }
762
- }
763
- },
764
- else: {
765
- properties: {
766
- explode: {
767
- default: false
768
- }
769
- }
770
- }
771
- }
772
- }
773
- },
774
- responses: {
775
- type: "object",
776
- properties: {
777
- default: {
778
- $ref: "#/$defs/response-or-reference"
779
- }
780
- },
781
- patternProperties: {
782
- "^[1-5](?:[0-9]{2}|XX)$": {
783
- $ref: "#/$defs/response-or-reference"
784
- }
785
- },
786
- $ref: "#/$defs/specification-extensions",
787
- unevaluatedProperties: false
788
- },
789
- response: {
790
- type: "object",
791
- properties: {
792
- description: {
793
- type: "string"
794
- },
795
- headers: {
796
- type: "object",
797
- additionalProperties: {
798
- $ref: "#/$defs/header-or-reference"
799
- }
800
- },
801
- content: {
802
- $ref: "#/$defs/content"
803
- },
804
- links: {
805
- type: "object",
806
- additionalProperties: {
807
- $ref: "#/$defs/link-or-reference"
808
- }
809
- }
810
- },
811
- required: [
812
- "description"
813
- ],
814
- $ref: "#/$defs/specification-extensions",
815
- unevaluatedProperties: false
816
- },
817
- "response-or-reference": {
818
- if: {
819
- type: "object",
820
- required: [
821
- "$ref"
822
- ]
823
- },
824
- then: {
825
- $ref: "#/$defs/reference"
826
- },
827
- else: {
828
- $ref: "#/$defs/response"
829
- }
830
- },
831
- callbacks: {
832
- type: "object",
833
- $ref: "#/$defs/specification-extensions",
834
- additionalProperties: {
835
- $ref: "#/$defs/path-item-or-reference"
836
- }
837
- },
838
- "callbacks-or-reference": {
839
- if: {
840
- type: "object",
841
- required: [
842
- "$ref"
843
- ]
844
- },
845
- then: {
846
- $ref: "#/$defs/reference"
847
- },
848
- else: {
849
- $ref: "#/$defs/callbacks"
850
- }
851
- },
852
- example: {
853
- type: "object",
854
- properties: {
855
- summary: {
856
- type: "string"
857
- },
858
- description: {
859
- type: "string"
860
- },
861
- value: true,
862
- externalValue: {
863
- type: "string",
864
- format: "uri"
865
- }
866
- },
867
- $ref: "#/$defs/specification-extensions",
868
- unevaluatedProperties: false
869
- },
870
- "example-or-reference": {
871
- if: {
872
- type: "object",
873
- required: [
874
- "$ref"
875
- ]
876
- },
877
- then: {
878
- $ref: "#/$defs/reference"
879
- },
880
- else: {
881
- $ref: "#/$defs/example"
882
- }
883
- },
884
- link: {
885
- type: "object",
886
- properties: {
887
- operationRef: {
888
- type: "string",
889
- format: "uri-reference"
890
- },
891
- operationId: true,
892
- parameters: {
893
- $ref: "#/$defs/map-of-strings"
894
- },
895
- requestBody: true,
896
- description: {
897
- type: "string"
898
- },
899
- body: {
900
- $ref: "#/$defs/server"
901
- }
902
- },
903
- oneOf: [
904
- {
905
- required: [
906
- "operationRef"
907
- ]
908
- },
909
- {
910
- required: [
911
- "operationId"
912
- ]
913
- }
914
- ],
915
- $ref: "#/$defs/specification-extensions",
916
- unevaluatedProperties: false
917
- },
918
- "link-or-reference": {
919
- if: {
920
- type: "object",
921
- required: [
922
- "$ref"
923
- ]
924
- },
925
- then: {
926
- $ref: "#/$defs/reference"
927
- },
928
- else: {
929
- $ref: "#/$defs/link"
930
- }
931
- },
932
- header: {
933
- type: "object",
934
- properties: {
935
- description: {
936
- type: "string"
937
- },
938
- required: {
939
- default: false,
940
- type: "boolean"
941
- },
942
- deprecated: {
943
- default: false,
944
- type: "boolean"
945
- },
946
- schema: {
947
- $dynamicRef: "#meta"
948
- },
949
- content: {
950
- $ref: "#/$defs/content"
951
- }
952
- },
953
- oneOf: [
954
- {
955
- required: [
956
- "schema"
957
- ]
958
- },
959
- {
960
- required: [
961
- "content"
962
- ]
963
- }
964
- ],
965
- dependentSchemas: {
966
- schema: {
967
- properties: {
968
- style: {
969
- default: "simple",
970
- const: "simple"
971
- },
972
- explode: {
973
- default: false,
974
- type: "boolean"
975
- }
976
- },
977
- $ref: "#/$defs/examples"
978
- }
979
- },
980
- $ref: "#/$defs/specification-extensions",
981
- unevaluatedProperties: false
982
- },
983
- "header-or-reference": {
984
- if: {
985
- type: "object",
986
- required: [
987
- "$ref"
988
- ]
989
- },
990
- then: {
991
- $ref: "#/$defs/reference"
992
- },
993
- else: {
994
- $ref: "#/$defs/header"
995
- }
996
- },
997
- tag: {
998
- type: "object",
999
- properties: {
1000
- name: {
1001
- type: "string"
1002
- },
1003
- description: {
1004
- type: "string"
1005
- },
1006
- externalDocs: {
1007
- $ref: "#/$defs/external-documentation"
1008
- }
1009
- },
1010
- required: [
1011
- "name"
1012
- ],
1013
- $ref: "#/$defs/specification-extensions",
1014
- unevaluatedProperties: false
1015
- },
1016
- reference: {
1017
- type: "object",
1018
- properties: {
1019
- $ref: {
1020
- type: "string",
1021
- format: "uri-reference"
1022
- },
1023
- summary: {
1024
- type: "string"
1025
- },
1026
- description: {
1027
- type: "string"
1028
- }
1029
- },
1030
- unevaluatedProperties: false
1031
- },
1032
- schema: {
1033
- $dynamicAnchor: "meta",
1034
- type: [
1035
- "object",
1036
- "boolean"
1037
- ]
1038
- },
1039
- "security-scheme": {
1040
- type: "object",
1041
- properties: {
1042
- type: {
1043
- enum: [
1044
- "apiKey",
1045
- "http",
1046
- "mutualTLS",
1047
- "oauth2",
1048
- "openIdConnect"
1049
- ]
1050
- },
1051
- description: {
1052
- type: "string"
1053
- }
1054
- },
1055
- required: [
1056
- "type"
1057
- ],
1058
- allOf: [
1059
- {
1060
- $ref: "#/$defs/specification-extensions"
1061
- },
1062
- {
1063
- $ref: "#/$defs/security-scheme/$defs/type-apikey"
1064
- },
1065
- {
1066
- $ref: "#/$defs/security-scheme/$defs/type-http"
1067
- },
1068
- {
1069
- $ref: "#/$defs/security-scheme/$defs/type-http-bearer"
1070
- },
1071
- {
1072
- $ref: "#/$defs/security-scheme/$defs/type-oauth2"
1073
- },
1074
- {
1075
- $ref: "#/$defs/security-scheme/$defs/type-oidc"
1076
- }
1077
- ],
1078
- unevaluatedProperties: false,
1079
- $defs: {
1080
- "type-apikey": {
1081
- if: {
1082
- properties: {
1083
- type: {
1084
- const: "apiKey"
1085
- }
1086
- },
1087
- required: [
1088
- "type"
1089
- ]
1090
- },
1091
- then: {
1092
- properties: {
1093
- name: {
1094
- type: "string"
1095
- },
1096
- in: {
1097
- enum: [
1098
- "query",
1099
- "header",
1100
- "cookie"
1101
- ]
1102
- }
1103
- },
1104
- required: [
1105
- "name",
1106
- "in"
1107
- ]
1108
- }
1109
- },
1110
- "type-http": {
1111
- if: {
1112
- properties: {
1113
- type: {
1114
- const: "http"
1115
- }
1116
- },
1117
- required: [
1118
- "type"
1119
- ]
1120
- },
1121
- then: {
1122
- properties: {
1123
- scheme: {
1124
- type: "string"
1125
- }
1126
- },
1127
- required: [
1128
- "scheme"
1129
- ]
1130
- }
1131
- },
1132
- "type-http-bearer": {
1133
- if: {
1134
- properties: {
1135
- type: {
1136
- const: "http"
1137
- },
1138
- scheme: {
1139
- type: "string",
1140
- pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
1141
- }
1142
- },
1143
- required: [
1144
- "type",
1145
- "scheme"
1146
- ]
1147
- },
1148
- then: {
1149
- properties: {
1150
- bearerFormat: {
1151
- type: "string"
1152
- }
1153
- }
1154
- }
1155
- },
1156
- "type-oauth2": {
1157
- if: {
1158
- properties: {
1159
- type: {
1160
- const: "oauth2"
1161
- }
1162
- },
1163
- required: [
1164
- "type"
1165
- ]
1166
- },
1167
- then: {
1168
- properties: {
1169
- flows: {
1170
- $ref: "#/$defs/oauth-flows"
1171
- }
1172
- },
1173
- required: [
1174
- "flows"
1175
- ]
1176
- }
1177
- },
1178
- "type-oidc": {
1179
- if: {
1180
- properties: {
1181
- type: {
1182
- const: "openIdConnect"
1183
- }
1184
- },
1185
- required: [
1186
- "type"
1187
- ]
1188
- },
1189
- then: {
1190
- properties: {
1191
- openIdConnectUrl: {
1192
- type: "string",
1193
- format: "uri"
1194
- }
1195
- },
1196
- required: [
1197
- "openIdConnectUrl"
1198
- ]
1199
- }
1200
- }
1201
- }
1202
- },
1203
- "security-scheme-or-reference": {
1204
- if: {
1205
- type: "object",
1206
- required: [
1207
- "$ref"
1208
- ]
1209
- },
1210
- then: {
1211
- $ref: "#/$defs/reference"
1212
- },
1213
- else: {
1214
- $ref: "#/$defs/security-scheme"
1215
- }
1216
- },
1217
- "oauth-flows": {
1218
- type: "object",
1219
- properties: {
1220
- implicit: {
1221
- $ref: "#/$defs/oauth-flows/$defs/implicit"
1222
- },
1223
- password: {
1224
- $ref: "#/$defs/oauth-flows/$defs/password"
1225
- },
1226
- clientCredentials: {
1227
- $ref: "#/$defs/oauth-flows/$defs/client-credentials"
1228
- },
1229
- authorizationCode: {
1230
- $ref: "#/$defs/oauth-flows/$defs/authorization-code"
1231
- }
1232
- },
1233
- $ref: "#/$defs/specification-extensions",
1234
- unevaluatedProperties: false,
1235
- $defs: {
1236
- implicit: {
1237
- type: "object",
1238
- properties: {
1239
- authorizationUrl: {
1240
- type: "string"
1241
- },
1242
- refreshUrl: {
1243
- type: "string"
1244
- },
1245
- scopes: {
1246
- $ref: "#/$defs/map-of-strings"
1247
- }
1248
- },
1249
- required: [
1250
- "authorizationUrl",
1251
- "scopes"
1252
- ],
1253
- $ref: "#/$defs/specification-extensions",
1254
- unevaluatedProperties: false
1255
- },
1256
- password: {
1257
- type: "object",
1258
- properties: {
1259
- tokenUrl: {
1260
- type: "string"
1261
- },
1262
- refreshUrl: {
1263
- type: "string"
1264
- },
1265
- scopes: {
1266
- $ref: "#/$defs/map-of-strings"
1267
- }
1268
- },
1269
- required: [
1270
- "tokenUrl",
1271
- "scopes"
1272
- ],
1273
- $ref: "#/$defs/specification-extensions",
1274
- unevaluatedProperties: false
1275
- },
1276
- "client-credentials": {
1277
- type: "object",
1278
- properties: {
1279
- tokenUrl: {
1280
- type: "string"
1281
- },
1282
- refreshUrl: {
1283
- type: "string"
1284
- },
1285
- scopes: {
1286
- $ref: "#/$defs/map-of-strings"
1287
- }
1288
- },
1289
- required: [
1290
- "tokenUrl",
1291
- "scopes"
1292
- ],
1293
- $ref: "#/$defs/specification-extensions",
1294
- unevaluatedProperties: false
1295
- },
1296
- "authorization-code": {
1297
- type: "object",
1298
- properties: {
1299
- authorizationUrl: {
1300
- type: "string"
1301
- },
1302
- tokenUrl: {
1303
- type: "string"
1304
- },
1305
- refreshUrl: {
1306
- type: "string"
1307
- },
1308
- scopes: {
1309
- $ref: "#/$defs/map-of-strings"
1310
- }
1311
- },
1312
- required: [
1313
- "authorizationUrl",
1314
- "tokenUrl",
1315
- "scopes"
1316
- ],
1317
- $ref: "#/$defs/specification-extensions",
1318
- unevaluatedProperties: false
1319
- }
1320
- }
1321
- },
1322
- "security-requirement": {
1323
- type: "object",
1324
- additionalProperties: {
1325
- type: "array",
1326
- items: {
1327
- type: "string"
1328
- }
1329
- }
1330
- },
1331
- "specification-extensions": {
1332
- patternProperties: {
1333
- "^x-": true
1334
- }
1335
- },
1336
- examples: {
1337
- properties: {
1338
- example: true,
1339
- examples: {
1340
- type: "object",
1341
- additionalProperties: {
1342
- $ref: "#/$defs/example-or-reference"
1343
- }
1344
- }
1345
- }
1346
- },
1347
- "map-of-strings": {
1348
- type: "object",
1349
- additionalProperties: {
1350
- type: "string"
1351
- }
1352
- }
1353
- }
1354
- };
1355
-
1356
- // src/schemas/v3_0.json
1357
- var v3_0_default = {
1358
- id: "https://spec.openapis.org/oas/3.0/schema/2021-09-28",
1359
- $schema: "http://json-schema.org/draft-04/schema#",
1360
- description: "Validation schema for OpenAPI Specification 3.0.X.",
1361
- type: "object",
1362
- required: [
1363
- "openapi",
1364
- "info",
1365
- "paths"
1366
- ],
1367
- properties: {
1368
- openapi: {
1369
- type: "string",
1370
- pattern: "^3\\.0\\.\\d(-.+)?$"
1371
- },
1372
- info: {
1373
- $ref: "#/definitions/Info"
1374
- },
1375
- externalDocs: {
1376
- $ref: "#/definitions/ExternalDocumentation"
1377
- },
1378
- servers: {
1379
- type: "array",
1380
- items: {
1381
- $ref: "#/definitions/Server"
1382
- }
1383
- },
1384
- security: {
1385
- type: "array",
1386
- items: {
1387
- $ref: "#/definitions/SecurityRequirement"
1388
- }
1389
- },
1390
- tags: {
1391
- type: "array",
1392
- items: {
1393
- $ref: "#/definitions/Tag"
1394
- },
1395
- uniqueItems: true
1396
- },
1397
- paths: {
1398
- $ref: "#/definitions/Paths"
1399
- },
1400
- components: {
1401
- $ref: "#/definitions/Components"
1402
- }
1403
- },
1404
- patternProperties: {
1405
- "^x-": {}
1406
- },
1407
- additionalProperties: false,
1408
- definitions: {
1409
- Reference: {
1410
- type: "object",
1411
- required: [
1412
- "$ref"
1413
- ],
1414
- patternProperties: {
1415
- "^\\$ref$": {
1416
- type: "string",
1417
- format: "uri-reference"
1418
- }
1419
- }
1420
- },
1421
- Info: {
1422
- type: "object",
1423
- required: [
1424
- "title",
1425
- "version"
1426
- ],
1427
- properties: {
1428
- title: {
1429
- type: "string"
1430
- },
1431
- description: {
1432
- type: "string"
1433
- },
1434
- termsOfService: {
1435
- type: "string",
1436
- format: "uri-reference"
1437
- },
1438
- contact: {
1439
- $ref: "#/definitions/Contact"
1440
- },
1441
- license: {
1442
- $ref: "#/definitions/License"
1443
- },
1444
- version: {
1445
- type: "string"
1446
- }
1447
- },
1448
- patternProperties: {
1449
- "^x-": {}
1450
- },
1451
- additionalProperties: false
1452
- },
1453
- Contact: {
1454
- type: "object",
1455
- properties: {
1456
- name: {
1457
- type: "string"
1458
- },
1459
- url: {
1460
- type: "string",
1461
- format: "uri-reference"
1462
- },
1463
- email: {
1464
- type: "string",
1465
- format: "email"
1466
- }
1467
- },
1468
- patternProperties: {
1469
- "^x-": {}
1470
- },
1471
- additionalProperties: false
1472
- },
1473
- License: {
1474
- type: "object",
1475
- required: [
1476
- "name"
1477
- ],
1478
- properties: {
1479
- name: {
1480
- type: "string"
1481
- },
1482
- url: {
1483
- type: "string",
1484
- format: "uri-reference"
1485
- }
1486
- },
1487
- patternProperties: {
1488
- "^x-": {}
1489
- },
1490
- additionalProperties: false
1491
- },
1492
- Server: {
1493
- type: "object",
1494
- required: [
1495
- "url"
1496
- ],
1497
- properties: {
1498
- url: {
1499
- type: "string"
1500
- },
1501
- description: {
1502
- type: "string"
1503
- },
1504
- variables: {
1505
- type: "object",
1506
- additionalProperties: {
1507
- $ref: "#/definitions/ServerVariable"
1508
- }
1509
- }
1510
- },
1511
- patternProperties: {
1512
- "^x-": {}
1513
- },
1514
- additionalProperties: false
1515
- },
1516
- ServerVariable: {
1517
- type: "object",
1518
- required: [
1519
- "default"
1520
- ],
1521
- properties: {
1522
- enum: {
1523
- type: "array",
1524
- items: {
1525
- type: "string"
1526
- }
1527
- },
1528
- default: {
1529
- type: "string"
1530
- },
1531
- description: {
1532
- type: "string"
1533
- }
1534
- },
1535
- patternProperties: {
1536
- "^x-": {}
1537
- },
1538
- additionalProperties: false
1539
- },
1540
- Components: {
1541
- type: "object",
1542
- properties: {
1543
- schemas: {
1544
- type: "object",
1545
- patternProperties: {
1546
- "^[a-zA-Z0-9\\.\\-_]+$": {
1547
- oneOf: [
1548
- {
1549
- $ref: "#/definitions/Schema"
1550
- },
1551
- {
1552
- $ref: "#/definitions/Reference"
1553
- }
1554
- ]
1555
- }
1556
- }
1557
- },
1558
- responses: {
1559
- type: "object",
1560
- patternProperties: {
1561
- "^[a-zA-Z0-9\\.\\-_]+$": {
1562
- oneOf: [
1563
- {
1564
- $ref: "#/definitions/Reference"
1565
- },
1566
- {
1567
- $ref: "#/definitions/Response"
1568
- }
1569
- ]
1570
- }
1571
- }
1572
- },
1573
- parameters: {
1574
- type: "object",
1575
- patternProperties: {
1576
- "^[a-zA-Z0-9\\.\\-_]+$": {
1577
- oneOf: [
1578
- {
1579
- $ref: "#/definitions/Reference"
1580
- },
1581
- {
1582
- $ref: "#/definitions/Parameter"
1583
- }
1584
- ]
1585
- }
1586
- }
1587
- },
1588
- examples: {
1589
- type: "object",
1590
- patternProperties: {
1591
- "^[a-zA-Z0-9\\.\\-_]+$": {
1592
- oneOf: [
1593
- {
1594
- $ref: "#/definitions/Reference"
1595
- },
1596
- {
1597
- $ref: "#/definitions/Example"
1598
- }
1599
- ]
1600
- }
1601
- }
1602
- },
1603
- requestBodies: {
1604
- type: "object",
1605
- patternProperties: {
1606
- "^[a-zA-Z0-9\\.\\-_]+$": {
1607
- oneOf: [
1608
- {
1609
- $ref: "#/definitions/Reference"
1610
- },
1611
- {
1612
- $ref: "#/definitions/RequestBody"
1613
- }
1614
- ]
1615
- }
1616
- }
1617
- },
1618
- headers: {
1619
- type: "object",
1620
- patternProperties: {
1621
- "^[a-zA-Z0-9\\.\\-_]+$": {
1622
- oneOf: [
1623
- {
1624
- $ref: "#/definitions/Reference"
1625
- },
1626
- {
1627
- $ref: "#/definitions/Header"
1628
- }
1629
- ]
1630
- }
1631
- }
1632
- },
1633
- securitySchemes: {
1634
- type: "object",
1635
- patternProperties: {
1636
- "^[a-zA-Z0-9\\.\\-_]+$": {
1637
- oneOf: [
1638
- {
1639
- $ref: "#/definitions/Reference"
1640
- },
1641
- {
1642
- $ref: "#/definitions/SecurityScheme"
1643
- }
1644
- ]
1645
- }
1646
- }
1647
- },
1648
- links: {
1649
- type: "object",
1650
- patternProperties: {
1651
- "^[a-zA-Z0-9\\.\\-_]+$": {
1652
- oneOf: [
1653
- {
1654
- $ref: "#/definitions/Reference"
1655
- },
1656
- {
1657
- $ref: "#/definitions/Link"
1658
- }
1659
- ]
1660
- }
1661
- }
1662
- },
1663
- callbacks: {
1664
- type: "object",
1665
- patternProperties: {
1666
- "^[a-zA-Z0-9\\.\\-_]+$": {
1667
- oneOf: [
1668
- {
1669
- $ref: "#/definitions/Reference"
1670
- },
1671
- {
1672
- $ref: "#/definitions/Callback"
1673
- }
1674
- ]
1675
- }
1676
- }
1677
- }
1678
- },
1679
- patternProperties: {
1680
- "^x-": {}
1681
- },
1682
- additionalProperties: false
1683
- },
1684
- Schema: {
1685
- type: "object",
1686
- properties: {
1687
- title: {
1688
- type: "string"
1689
- },
1690
- multipleOf: {
1691
- type: "number",
1692
- minimum: 0,
1693
- exclusiveMinimum: true
1694
- },
1695
- maximum: {
1696
- type: "number"
1697
- },
1698
- exclusiveMaximum: {
1699
- type: "boolean",
1700
- default: false
1701
- },
1702
- minimum: {
1703
- type: "number"
1704
- },
1705
- exclusiveMinimum: {
1706
- type: "boolean",
1707
- default: false
1708
- },
1709
- maxLength: {
1710
- type: "integer",
1711
- minimum: 0
1712
- },
1713
- minLength: {
1714
- type: "integer",
1715
- minimum: 0,
1716
- default: 0
1717
- },
1718
- pattern: {
1719
- type: "string",
1720
- format: "regex"
1721
- },
1722
- maxItems: {
1723
- type: "integer",
1724
- minimum: 0
1725
- },
1726
- minItems: {
1727
- type: "integer",
1728
- minimum: 0,
1729
- default: 0
1730
- },
1731
- uniqueItems: {
1732
- type: "boolean",
1733
- default: false
1734
- },
1735
- maxProperties: {
1736
- type: "integer",
1737
- minimum: 0
1738
- },
1739
- minProperties: {
1740
- type: "integer",
1741
- minimum: 0,
1742
- default: 0
1743
- },
1744
- required: {
1745
- type: "array",
1746
- items: {
1747
- type: "string"
1748
- },
1749
- minItems: 1,
1750
- uniqueItems: true
1751
- },
1752
- enum: {
1753
- type: "array",
1754
- items: {},
1755
- minItems: 1,
1756
- uniqueItems: false
1757
- },
1758
- type: {
1759
- type: "string",
1760
- enum: [
1761
- "array",
1762
- "boolean",
1763
- "integer",
1764
- "number",
1765
- "object",
1766
- "string"
1767
- ]
1768
- },
1769
- not: {
1770
- oneOf: [
1771
- {
1772
- $ref: "#/definitions/Schema"
1773
- },
1774
- {
1775
- $ref: "#/definitions/Reference"
1776
- }
1777
- ]
1778
- },
1779
- allOf: {
1780
- type: "array",
1781
- items: {
1782
- oneOf: [
1783
- {
1784
- $ref: "#/definitions/Schema"
1785
- },
1786
- {
1787
- $ref: "#/definitions/Reference"
1788
- }
1789
- ]
1790
- }
1791
- },
1792
- oneOf: {
1793
- type: "array",
1794
- items: {
1795
- oneOf: [
1796
- {
1797
- $ref: "#/definitions/Schema"
1798
- },
1799
- {
1800
- $ref: "#/definitions/Reference"
1801
- }
1802
- ]
1803
- }
1804
- },
1805
- anyOf: {
1806
- type: "array",
1807
- items: {
1808
- oneOf: [
1809
- {
1810
- $ref: "#/definitions/Schema"
1811
- },
1812
- {
1813
- $ref: "#/definitions/Reference"
1814
- }
1815
- ]
1816
- }
1817
- },
1818
- items: {
1819
- oneOf: [
1820
- {
1821
- $ref: "#/definitions/Schema"
1822
- },
1823
- {
1824
- $ref: "#/definitions/Reference"
1825
- }
1826
- ]
1827
- },
1828
- properties: {
1829
- type: "object",
1830
- additionalProperties: {
1831
- oneOf: [
1832
- {
1833
- $ref: "#/definitions/Schema"
1834
- },
1835
- {
1836
- $ref: "#/definitions/Reference"
1837
- }
1838
- ]
1839
- }
1840
- },
1841
- additionalProperties: {
1842
- oneOf: [
1843
- {
1844
- $ref: "#/definitions/Schema"
1845
- },
1846
- {
1847
- $ref: "#/definitions/Reference"
1848
- },
1849
- {
1850
- type: "boolean"
1851
- }
1852
- ],
1853
- default: true
1854
- },
1855
- description: {
1856
- type: "string"
1857
- },
1858
- format: {
1859
- type: "string"
1860
- },
1861
- default: {},
1862
- nullable: {
1863
- type: "boolean",
1864
- default: false
1865
- },
1866
- discriminator: {
1867
- $ref: "#/definitions/Discriminator"
1868
- },
1869
- readOnly: {
1870
- type: "boolean",
1871
- default: false
1872
- },
1873
- writeOnly: {
1874
- type: "boolean",
1875
- default: false
1876
- },
1877
- example: {},
1878
- externalDocs: {
1879
- $ref: "#/definitions/ExternalDocumentation"
1880
- },
1881
- deprecated: {
1882
- type: "boolean",
1883
- default: false
1884
- },
1885
- xml: {
1886
- $ref: "#/definitions/XML"
1887
- }
1888
- },
1889
- patternProperties: {
1890
- "^x-": {}
1891
- },
1892
- additionalProperties: false
1893
- },
1894
- Discriminator: {
1895
- type: "object",
1896
- required: [
1897
- "propertyName"
1898
- ],
1899
- properties: {
1900
- propertyName: {
1901
- type: "string"
1902
- },
1903
- mapping: {
1904
- type: "object",
1905
- additionalProperties: {
1906
- type: "string"
1907
- }
1908
- }
1909
- }
1910
- },
1911
- XML: {
1912
- type: "object",
1913
- properties: {
1914
- name: {
1915
- type: "string"
1916
- },
1917
- namespace: {
1918
- type: "string",
1919
- format: "uri"
1920
- },
1921
- prefix: {
1922
- type: "string"
1923
- },
1924
- attribute: {
1925
- type: "boolean",
1926
- default: false
1927
- },
1928
- wrapped: {
1929
- type: "boolean",
1930
- default: false
1931
- }
1932
- },
1933
- patternProperties: {
1934
- "^x-": {}
1935
- },
1936
- additionalProperties: false
1937
- },
1938
- Response: {
1939
- type: "object",
1940
- required: [
1941
- "description"
1942
- ],
1943
- properties: {
1944
- description: {
1945
- type: "string"
1946
- },
1947
- headers: {
1948
- type: "object",
1949
- additionalProperties: {
1950
- oneOf: [
1951
- {
1952
- $ref: "#/definitions/Header"
1953
- },
1954
- {
1955
- $ref: "#/definitions/Reference"
1956
- }
1957
- ]
1958
- }
1959
- },
1960
- content: {
1961
- type: "object",
1962
- additionalProperties: {
1963
- $ref: "#/definitions/MediaType"
1964
- }
1965
- },
1966
- links: {
1967
- type: "object",
1968
- additionalProperties: {
1969
- oneOf: [
1970
- {
1971
- $ref: "#/definitions/Link"
1972
- },
1973
- {
1974
- $ref: "#/definitions/Reference"
1975
- }
1976
- ]
1977
- }
1978
- }
1979
- },
1980
- patternProperties: {
1981
- "^x-": {}
1982
- },
1983
- additionalProperties: false
1984
- },
1985
- MediaType: {
1986
- type: "object",
1987
- properties: {
1988
- schema: {
1989
- oneOf: [
1990
- {
1991
- $ref: "#/definitions/Schema"
1992
- },
1993
- {
1994
- $ref: "#/definitions/Reference"
1995
- }
1996
- ]
1997
- },
1998
- example: {},
1999
- examples: {
2000
- type: "object",
2001
- additionalProperties: {
2002
- oneOf: [
2003
- {
2004
- $ref: "#/definitions/Example"
2005
- },
2006
- {
2007
- $ref: "#/definitions/Reference"
2008
- }
2009
- ]
2010
- }
2011
- },
2012
- encoding: {
2013
- type: "object",
2014
- additionalProperties: {
2015
- $ref: "#/definitions/Encoding"
2016
- }
2017
- }
2018
- },
2019
- patternProperties: {
2020
- "^x-": {}
2021
- },
2022
- additionalProperties: false,
2023
- allOf: [
2024
- {
2025
- $ref: "#/definitions/ExampleXORExamples"
2026
- }
2027
- ]
2028
- },
2029
- Example: {
2030
- type: "object",
2031
- properties: {
2032
- summary: {
2033
- type: "string"
2034
- },
2035
- description: {
2036
- type: "string"
2037
- },
2038
- value: {},
2039
- externalValue: {
2040
- type: "string",
2041
- format: "uri-reference"
2042
- }
2043
- },
2044
- patternProperties: {
2045
- "^x-": {}
2046
- },
2047
- additionalProperties: false
2048
- },
2049
- Header: {
2050
- type: "object",
2051
- properties: {
2052
- description: {
2053
- type: "string"
2054
- },
2055
- required: {
2056
- type: "boolean",
2057
- default: false
2058
- },
2059
- deprecated: {
2060
- type: "boolean",
2061
- default: false
2062
- },
2063
- allowEmptyValue: {
2064
- type: "boolean",
2065
- default: false
2066
- },
2067
- style: {
2068
- type: "string",
2069
- enum: [
2070
- "simple"
2071
- ],
2072
- default: "simple"
2073
- },
2074
- explode: {
2075
- type: "boolean"
2076
- },
2077
- allowReserved: {
2078
- type: "boolean",
2079
- default: false
2080
- },
2081
- schema: {
2082
- oneOf: [
2083
- {
2084
- $ref: "#/definitions/Schema"
2085
- },
2086
- {
2087
- $ref: "#/definitions/Reference"
2088
- }
2089
- ]
2090
- },
2091
- content: {
2092
- type: "object",
2093
- additionalProperties: {
2094
- $ref: "#/definitions/MediaType"
2095
- },
2096
- minProperties: 1,
2097
- maxProperties: 1
2098
- },
2099
- example: {},
2100
- examples: {
2101
- type: "object",
2102
- additionalProperties: {
2103
- oneOf: [
2104
- {
2105
- $ref: "#/definitions/Example"
2106
- },
2107
- {
2108
- $ref: "#/definitions/Reference"
2109
- }
2110
- ]
2111
- }
2112
- }
2113
- },
2114
- patternProperties: {
2115
- "^x-": {}
2116
- },
2117
- additionalProperties: false,
2118
- allOf: [
2119
- {
2120
- $ref: "#/definitions/ExampleXORExamples"
2121
- },
2122
- {
2123
- $ref: "#/definitions/SchemaXORContent"
2124
- }
2125
- ]
2126
- },
2127
- Paths: {
2128
- type: "object",
2129
- patternProperties: {
2130
- "^\\/": {
2131
- $ref: "#/definitions/PathItem"
2132
- },
2133
- "^x-": {}
2134
- },
2135
- additionalProperties: false
2136
- },
2137
- PathItem: {
2138
- type: "object",
2139
- properties: {
2140
- $ref: {
2141
- type: "string"
2142
- },
2143
- summary: {
2144
- type: "string"
2145
- },
2146
- description: {
2147
- type: "string"
2148
- },
2149
- servers: {
2150
- type: "array",
2151
- items: {
2152
- $ref: "#/definitions/Server"
2153
- }
2154
- },
2155
- parameters: {
2156
- type: "array",
2157
- items: {
2158
- oneOf: [
2159
- {
2160
- $ref: "#/definitions/Parameter"
2161
- },
2162
- {
2163
- $ref: "#/definitions/Reference"
2164
- }
2165
- ]
2166
- },
2167
- uniqueItems: true
2168
- }
2169
- },
2170
- patternProperties: {
2171
- "^(get|put|post|delete|options|head|patch|trace)$": {
2172
- $ref: "#/definitions/Operation"
2173
- },
2174
- "^x-": {}
2175
- },
2176
- additionalProperties: false
2177
- },
2178
- Operation: {
2179
- type: "object",
2180
- required: [
2181
- "responses"
2182
- ],
2183
- properties: {
2184
- tags: {
2185
- type: "array",
2186
- items: {
2187
- type: "string"
2188
- }
2189
- },
2190
- summary: {
2191
- type: "string"
2192
- },
2193
- description: {
2194
- type: "string"
2195
- },
2196
- externalDocs: {
2197
- $ref: "#/definitions/ExternalDocumentation"
2198
- },
2199
- operationId: {
2200
- type: "string"
2201
- },
2202
- parameters: {
2203
- type: "array",
2204
- items: {
2205
- oneOf: [
2206
- {
2207
- $ref: "#/definitions/Parameter"
2208
- },
2209
- {
2210
- $ref: "#/definitions/Reference"
2211
- }
2212
- ]
2213
- },
2214
- uniqueItems: true
2215
- },
2216
- requestBody: {
2217
- oneOf: [
2218
- {
2219
- $ref: "#/definitions/RequestBody"
2220
- },
2221
- {
2222
- $ref: "#/definitions/Reference"
2223
- }
2224
- ]
2225
- },
2226
- responses: {
2227
- $ref: "#/definitions/Responses"
2228
- },
2229
- callbacks: {
2230
- type: "object",
2231
- additionalProperties: {
2232
- oneOf: [
2233
- {
2234
- $ref: "#/definitions/Callback"
2235
- },
2236
- {
2237
- $ref: "#/definitions/Reference"
2238
- }
2239
- ]
2240
- }
2241
- },
2242
- deprecated: {
2243
- type: "boolean",
2244
- default: false
2245
- },
2246
- security: {
2247
- type: "array",
2248
- items: {
2249
- $ref: "#/definitions/SecurityRequirement"
2250
- }
2251
- },
2252
- servers: {
2253
- type: "array",
2254
- items: {
2255
- $ref: "#/definitions/Server"
2256
- }
2257
- }
2258
- },
2259
- patternProperties: {
2260
- "^x-": {}
2261
- },
2262
- additionalProperties: false
2263
- },
2264
- Responses: {
2265
- type: "object",
2266
- properties: {
2267
- default: {
2268
- oneOf: [
2269
- {
2270
- $ref: "#/definitions/Response"
2271
- },
2272
- {
2273
- $ref: "#/definitions/Reference"
2274
- }
2275
- ]
2276
- }
2277
- },
2278
- patternProperties: {
2279
- "^[1-5](?:\\d{2}|XX)$": {
2280
- oneOf: [
2281
- {
2282
- $ref: "#/definitions/Response"
2283
- },
2284
- {
2285
- $ref: "#/definitions/Reference"
2286
- }
2287
- ]
2288
- },
2289
- "^x-": {}
2290
- },
2291
- minProperties: 1,
2292
- additionalProperties: false
2293
- },
2294
- SecurityRequirement: {
2295
- type: "object",
2296
- additionalProperties: {
2297
- type: "array",
2298
- items: {
2299
- type: "string"
2300
- }
2301
- }
2302
- },
2303
- Tag: {
2304
- type: "object",
2305
- required: [
2306
- "name"
2307
- ],
2308
- properties: {
2309
- name: {
2310
- type: "string"
2311
- },
2312
- description: {
2313
- type: "string"
2314
- },
2315
- externalDocs: {
2316
- $ref: "#/definitions/ExternalDocumentation"
2317
- }
2318
- },
2319
- patternProperties: {
2320
- "^x-": {}
2321
- },
2322
- additionalProperties: false
2323
- },
2324
- ExternalDocumentation: {
2325
- type: "object",
2326
- required: [
2327
- "url"
2328
- ],
2329
- properties: {
2330
- description: {
2331
- type: "string"
2332
- },
2333
- url: {
2334
- type: "string",
2335
- format: "uri-reference"
2336
- }
2337
- },
2338
- patternProperties: {
2339
- "^x-": {}
2340
- },
2341
- additionalProperties: false
2342
- },
2343
- ExampleXORExamples: {
2344
- description: "Example and examples are mutually exclusive",
2345
- not: {
2346
- required: [
2347
- "example",
2348
- "examples"
2349
- ]
2350
- }
2351
- },
2352
- SchemaXORContent: {
2353
- description: "Schema and content are mutually exclusive, at least one is required",
2354
- not: {
2355
- required: [
2356
- "schema",
2357
- "content"
2358
- ]
2359
- },
2360
- oneOf: [
2361
- {
2362
- required: [
2363
- "schema"
2364
- ]
2365
- },
2366
- {
2367
- required: [
2368
- "content"
2369
- ],
2370
- description: "Some properties are not allowed if content is present",
2371
- allOf: [
2372
- {
2373
- not: {
2374
- required: [
2375
- "style"
2376
- ]
2377
- }
2378
- },
2379
- {
2380
- not: {
2381
- required: [
2382
- "explode"
2383
- ]
2384
- }
2385
- },
2386
- {
2387
- not: {
2388
- required: [
2389
- "allowReserved"
2390
- ]
2391
- }
2392
- },
2393
- {
2394
- not: {
2395
- required: [
2396
- "example"
2397
- ]
2398
- }
2399
- },
2400
- {
2401
- not: {
2402
- required: [
2403
- "examples"
2404
- ]
2405
- }
2406
- }
2407
- ]
2408
- }
2409
- ]
2410
- },
2411
- Parameter: {
2412
- type: "object",
2413
- properties: {
2414
- name: {
2415
- type: "string"
2416
- },
2417
- in: {
2418
- type: "string"
2419
- },
2420
- description: {
2421
- type: "string"
2422
- },
2423
- required: {
2424
- type: "boolean",
2425
- default: false
2426
- },
2427
- deprecated: {
2428
- type: "boolean",
2429
- default: false
2430
- },
2431
- allowEmptyValue: {
2432
- type: "boolean",
2433
- default: false
2434
- },
2435
- style: {
2436
- type: "string"
2437
- },
2438
- explode: {
2439
- type: "boolean"
2440
- },
2441
- allowReserved: {
2442
- type: "boolean",
2443
- default: false
2444
- },
2445
- schema: {
2446
- oneOf: [
2447
- {
2448
- $ref: "#/definitions/Schema"
2449
- },
2450
- {
2451
- $ref: "#/definitions/Reference"
2452
- }
2453
- ]
2454
- },
2455
- content: {
2456
- type: "object",
2457
- additionalProperties: {
2458
- $ref: "#/definitions/MediaType"
2459
- },
2460
- minProperties: 1,
2461
- maxProperties: 1
2462
- },
2463
- example: {},
2464
- examples: {
2465
- type: "object",
2466
- additionalProperties: {
2467
- oneOf: [
2468
- {
2469
- $ref: "#/definitions/Example"
2470
- },
2471
- {
2472
- $ref: "#/definitions/Reference"
2473
- }
2474
- ]
2475
- }
2476
- }
2477
- },
2478
- patternProperties: {
2479
- "^x-": {}
2480
- },
2481
- additionalProperties: false,
2482
- required: [
2483
- "name",
2484
- "in"
2485
- ],
2486
- allOf: [
2487
- {
2488
- $ref: "#/definitions/ExampleXORExamples"
2489
- },
2490
- {
2491
- $ref: "#/definitions/SchemaXORContent"
2492
- },
2493
- {
2494
- $ref: "#/definitions/ParameterLocation"
2495
- }
2496
- ]
2497
- },
2498
- ParameterLocation: {
2499
- description: "Parameter location",
2500
- oneOf: [
2501
- {
2502
- description: "Parameter in path",
2503
- required: [
2504
- "required"
2505
- ],
2506
- properties: {
2507
- in: {
2508
- enum: [
2509
- "path"
2510
- ]
2511
- },
2512
- style: {
2513
- enum: [
2514
- "matrix",
2515
- "label",
2516
- "simple"
2517
- ],
2518
- default: "simple"
2519
- },
2520
- required: {
2521
- enum: [
2522
- true
2523
- ]
2524
- }
2525
- }
2526
- },
2527
- {
2528
- description: "Parameter in query",
2529
- properties: {
2530
- in: {
2531
- enum: [
2532
- "query"
2533
- ]
2534
- },
2535
- style: {
2536
- enum: [
2537
- "form",
2538
- "spaceDelimited",
2539
- "pipeDelimited",
2540
- "deepObject"
2541
- ],
2542
- default: "form"
2543
- }
2544
- }
2545
- },
2546
- {
2547
- description: "Parameter in header",
2548
- properties: {
2549
- in: {
2550
- enum: [
2551
- "header"
2552
- ]
2553
- },
2554
- style: {
2555
- enum: [
2556
- "simple"
2557
- ],
2558
- default: "simple"
2559
- }
2560
- }
2561
- },
2562
- {
2563
- description: "Parameter in cookie",
2564
- properties: {
2565
- in: {
2566
- enum: [
2567
- "cookie"
2568
- ]
2569
- },
2570
- style: {
2571
- enum: [
2572
- "form"
2573
- ],
2574
- default: "form"
2575
- }
2576
- }
2577
- }
2578
- ]
2579
- },
2580
- RequestBody: {
2581
- type: "object",
2582
- required: [
2583
- "content"
2584
- ],
2585
- properties: {
2586
- description: {
2587
- type: "string"
2588
- },
2589
- content: {
2590
- type: "object",
2591
- additionalProperties: {
2592
- $ref: "#/definitions/MediaType"
2593
- }
2594
- },
2595
- required: {
2596
- type: "boolean",
2597
- default: false
2598
- }
2599
- },
2600
- patternProperties: {
2601
- "^x-": {}
2602
- },
2603
- additionalProperties: false
2604
- },
2605
- SecurityScheme: {
2606
- oneOf: [
2607
- {
2608
- $ref: "#/definitions/APIKeySecurityScheme"
2609
- },
2610
- {
2611
- $ref: "#/definitions/HTTPSecurityScheme"
2612
- },
2613
- {
2614
- $ref: "#/definitions/OAuth2SecurityScheme"
2615
- },
2616
- {
2617
- $ref: "#/definitions/OpenIdConnectSecurityScheme"
2618
- }
2619
- ]
2620
- },
2621
- APIKeySecurityScheme: {
2622
- type: "object",
2623
- required: [
2624
- "type",
2625
- "name",
2626
- "in"
2627
- ],
2628
- properties: {
2629
- type: {
2630
- type: "string",
2631
- enum: [
2632
- "apiKey"
2633
- ]
2634
- },
2635
- name: {
2636
- type: "string"
2637
- },
2638
- in: {
2639
- type: "string",
2640
- enum: [
2641
- "header",
2642
- "query",
2643
- "cookie"
2644
- ]
2645
- },
2646
- description: {
2647
- type: "string"
2648
- }
2649
- },
2650
- patternProperties: {
2651
- "^x-": {}
2652
- },
2653
- additionalProperties: false
2654
- },
2655
- HTTPSecurityScheme: {
2656
- type: "object",
2657
- required: [
2658
- "scheme",
2659
- "type"
2660
- ],
2661
- properties: {
2662
- scheme: {
2663
- type: "string"
2664
- },
2665
- bearerFormat: {
2666
- type: "string"
2667
- },
2668
- description: {
2669
- type: "string"
2670
- },
2671
- type: {
2672
- type: "string",
2673
- enum: [
2674
- "http"
2675
- ]
2676
- }
2677
- },
2678
- patternProperties: {
2679
- "^x-": {}
2680
- },
2681
- additionalProperties: false,
2682
- oneOf: [
2683
- {
2684
- description: "Bearer",
2685
- properties: {
2686
- scheme: {
2687
- type: "string",
2688
- pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
2689
- }
2690
- }
2691
- },
2692
- {
2693
- description: "Non Bearer",
2694
- not: {
2695
- required: [
2696
- "bearerFormat"
2697
- ]
2698
- },
2699
- properties: {
2700
- scheme: {
2701
- not: {
2702
- type: "string",
2703
- pattern: "^[Bb][Ee][Aa][Rr][Ee][Rr]$"
2704
- }
2705
- }
2706
- }
2707
- }
2708
- ]
2709
- },
2710
- OAuth2SecurityScheme: {
2711
- type: "object",
2712
- required: [
2713
- "type",
2714
- "flows"
2715
- ],
2716
- properties: {
2717
- type: {
2718
- type: "string",
2719
- enum: [
2720
- "oauth2"
2721
- ]
2722
- },
2723
- flows: {
2724
- $ref: "#/definitions/OAuthFlows"
2725
- },
2726
- description: {
2727
- type: "string"
2728
- }
2729
- },
2730
- patternProperties: {
2731
- "^x-": {}
2732
- },
2733
- additionalProperties: false
2734
- },
2735
- OpenIdConnectSecurityScheme: {
2736
- type: "object",
2737
- required: [
2738
- "type",
2739
- "openIdConnectUrl"
2740
- ],
2741
- properties: {
2742
- type: {
2743
- type: "string",
2744
- enum: [
2745
- "openIdConnect"
2746
- ]
2747
- },
2748
- openIdConnectUrl: {
2749
- type: "string",
2750
- format: "uri-reference"
2751
- },
2752
- description: {
2753
- type: "string"
2754
- }
2755
- },
2756
- patternProperties: {
2757
- "^x-": {}
2758
- },
2759
- additionalProperties: false
2760
- },
2761
- OAuthFlows: {
2762
- type: "object",
2763
- properties: {
2764
- implicit: {
2765
- $ref: "#/definitions/ImplicitOAuthFlow"
2766
- },
2767
- password: {
2768
- $ref: "#/definitions/PasswordOAuthFlow"
2769
- },
2770
- clientCredentials: {
2771
- $ref: "#/definitions/ClientCredentialsFlow"
2772
- },
2773
- authorizationCode: {
2774
- $ref: "#/definitions/AuthorizationCodeOAuthFlow"
2775
- }
2776
- },
2777
- patternProperties: {
2778
- "^x-": {}
2779
- },
2780
- additionalProperties: false
2781
- },
2782
- ImplicitOAuthFlow: {
2783
- type: "object",
2784
- required: [
2785
- "authorizationUrl",
2786
- "scopes"
2787
- ],
2788
- properties: {
2789
- authorizationUrl: {
2790
- type: "string",
2791
- format: "uri-reference"
2792
- },
2793
- refreshUrl: {
2794
- type: "string",
2795
- format: "uri-reference"
2796
- },
2797
- scopes: {
2798
- type: "object",
2799
- additionalProperties: {
2800
- type: "string"
2801
- }
2802
- }
2803
- },
2804
- patternProperties: {
2805
- "^x-": {}
2806
- },
2807
- additionalProperties: false
2808
- },
2809
- PasswordOAuthFlow: {
2810
- type: "object",
2811
- required: [
2812
- "tokenUrl",
2813
- "scopes"
2814
- ],
2815
- properties: {
2816
- tokenUrl: {
2817
- type: "string",
2818
- format: "uri-reference"
2819
- },
2820
- refreshUrl: {
2821
- type: "string",
2822
- format: "uri-reference"
2823
- },
2824
- scopes: {
2825
- type: "object",
2826
- additionalProperties: {
2827
- type: "string"
2828
- }
2829
- }
2830
- },
2831
- patternProperties: {
2832
- "^x-": {}
2833
- },
2834
- additionalProperties: false
2835
- },
2836
- ClientCredentialsFlow: {
2837
- type: "object",
2838
- required: [
2839
- "tokenUrl",
2840
- "scopes"
2841
- ],
2842
- properties: {
2843
- tokenUrl: {
2844
- type: "string",
2845
- format: "uri-reference"
2846
- },
2847
- refreshUrl: {
2848
- type: "string",
2849
- format: "uri-reference"
2850
- },
2851
- scopes: {
2852
- type: "object",
2853
- additionalProperties: {
2854
- type: "string"
2855
- }
2856
- }
2857
- },
2858
- patternProperties: {
2859
- "^x-": {}
2860
- },
2861
- additionalProperties: false
2862
- },
2863
- AuthorizationCodeOAuthFlow: {
2864
- type: "object",
2865
- required: [
2866
- "authorizationUrl",
2867
- "tokenUrl",
2868
- "scopes"
2869
- ],
2870
- properties: {
2871
- authorizationUrl: {
2872
- type: "string",
2873
- format: "uri-reference"
2874
- },
2875
- tokenUrl: {
2876
- type: "string",
2877
- format: "uri-reference"
2878
- },
2879
- refreshUrl: {
2880
- type: "string",
2881
- format: "uri-reference"
2882
- },
2883
- scopes: {
2884
- type: "object",
2885
- additionalProperties: {
2886
- type: "string"
2887
- }
2888
- }
2889
- },
2890
- patternProperties: {
2891
- "^x-": {}
2892
- },
2893
- additionalProperties: false
2894
- },
2895
- Link: {
2896
- type: "object",
2897
- properties: {
2898
- operationId: {
2899
- type: "string"
2900
- },
2901
- operationRef: {
2902
- type: "string",
2903
- format: "uri-reference"
2904
- },
2905
- parameters: {
2906
- type: "object",
2907
- additionalProperties: {}
2908
- },
2909
- requestBody: {},
2910
- description: {
2911
- type: "string"
2912
- },
2913
- server: {
2914
- $ref: "#/definitions/Server"
2915
- }
2916
- },
2917
- patternProperties: {
2918
- "^x-": {}
2919
- },
2920
- additionalProperties: false,
2921
- not: {
2922
- description: "Operation Id and Operation Ref are mutually exclusive",
2923
- required: [
2924
- "operationId",
2925
- "operationRef"
2926
- ]
2927
- }
2928
- },
2929
- Callback: {
2930
- type: "object",
2931
- additionalProperties: {
2932
- $ref: "#/definitions/PathItem"
2933
- },
2934
- patternProperties: {
2935
- "^x-": {}
2936
- }
2937
- },
2938
- Encoding: {
2939
- type: "object",
2940
- properties: {
2941
- contentType: {
2942
- type: "string"
2943
- },
2944
- headers: {
2945
- type: "object",
2946
- additionalProperties: {
2947
- oneOf: [
2948
- {
2949
- $ref: "#/definitions/Header"
2950
- },
2951
- {
2952
- $ref: "#/definitions/Reference"
2953
- }
2954
- ]
2955
- }
2956
- },
2957
- style: {
2958
- type: "string",
2959
- enum: [
2960
- "form",
2961
- "spaceDelimited",
2962
- "pipeDelimited",
2963
- "deepObject"
2964
- ]
2965
- },
2966
- explode: {
2967
- type: "boolean"
2968
- },
2969
- allowReserved: {
2970
- type: "boolean",
2971
- default: false
2972
- }
2973
- },
2974
- additionalProperties: false
2975
- }
2976
- }
2977
- };
2978
-
2979
- // src/validator.ts
2980
- var schemas = {
2981
- "3_1": [v3_1_default, "https://json-schema.hyperjump.io/schema", "https://json-schema.org/draft/2020-12/schema"],
2982
- "3_0": [v3_0_default, "https://json-schema.hyperjump.io/schema", "http://json-schema.org/draft-04/schema#"]
2
+ import { validate as validateOpenapi30 } from "@hyperjump/json-schema/openapi-3-0";
3
+ import { validate as validateOpenapi31 } from "@hyperjump/json-schema/openapi-3-1";
4
+ import { BASIC } from "@hyperjump/json-schema/experimental";
5
+ var dialects = {
6
+ "3_0": { uri: "https://spec.openapis.org/oas/3.0/schema", validate: validateOpenapi30 },
7
+ "3_1": { uri: "https://spec.openapis.org/oas/3.1/schema-base", validate: validateOpenapi31 }
2983
8
  };
2984
9
  var validator = async (openapi) => {
2985
- const params = schemas[openapi.openapi.split(".").slice(0, 2).join("_")];
2986
- if (!params) {
10
+ const version = openapi.openapi.split(".").slice(0, 2).join("_");
11
+ const dialect = dialects[version];
12
+ if (!dialect) {
2987
13
  throw new Error("Not supported version.\nopenapi version 3.0.0 >= version < 3.2.0");
2988
14
  }
2989
- JsonSchema.add(...params);
2990
- const schema = await JsonSchema.get("https://json-schema.hyperjump.io/schema");
2991
- return JsonSchema.validate(schema, openapi, JsonSchema.DETAILED).then((result) => ({
2992
- valid: result.valid,
2993
- errors: errorExtractor(result)
2994
- }));
2995
- };
2996
- var errorExtractor = (result) => {
2997
- if (!result.errors || result.errors?.length === 0) {
2998
- return [{
2999
- keyword: result.keyword.split("#").slice(-1, 2)[0] ?? "",
3000
- rule: result.absoluteKeywordLocation.split("#").slice(-1, 2)[0] ?? "",
3001
- location: result.instanceLocation
3002
- }];
3003
- }
3004
- return result.errors.map((res) => [...errorExtractor(res)]).flat();
15
+ const output = await dialect.validate(dialect.uri, openapi, BASIC);
16
+ return { valid: output.valid, errors: errorExtractor(output) };
3005
17
  };
18
+ var errorExtractor = (output) => (output.errors ?? []).map((error) => ({
19
+ keyword: error.keyword?.split("/").pop() ?? "",
20
+ rule: error.absoluteKeywordLocation?.split("#")[1] ?? "",
21
+ location: error.instanceLocation ?? ""
22
+ }));
3006
23
  export {
3007
24
  validator
3008
25
  };