-
Notifications
You must be signed in to change notification settings - Fork 0
/
.spectral.json
1284 lines (1284 loc) · 51 KB
/
.spectral.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"description": "",
"formats": [
"oas2",
"oas3",
"oas3.0",
"oas3.1"
],
"aliases": {
"API_Document": {
"description": "The complete API specification document. This can be used to target any part of the OpenAPI document using **field**.\n\n*Use this if you don't find specific targets that cater to your usecase.* ",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$"
]
},
{
"formats": [
"oas3"
],
"given": [
"$"
]
}
]
},
"API_Description": {
"description": "The top level description in an API document",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.info.description"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.info.description"
]
}
]
},
"Operation_Object": {
"description": "The complete operation object. Use it in combo with field object.",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"#Path_Item[get,put,post,delete,options,head,patch,trace]"
]
},
{
"formats": [
"oas3"
],
"given": [
"#Path_Item[get,put,post,delete,options,head,patch,trace]"
]
}
]
},
"Operation_Responses": {
"description": "Responses for all operations including get, put, post, delete, options, head, patch, trace.",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"#Operation_Object.responses"
]
},
{
"formats": [
"oas3"
],
"given": [
"#Operation_Object.responses"
]
}
]
},
"Path_Item": {
"description": "",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.paths[*]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.paths[*]"
]
}
]
},
"API_Contact": {
"description": "The top level description in an API document",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.info.contact"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.info.contact"
]
}
]
},
"API_License": {
"description": "The top level description in an API document",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.info.license"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.info.license"
]
}
]
},
"All_Markdown": {
"description": "All markdown descriptions across the document.",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..[description,title]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..[description,title]"
]
}
]
},
"API_Tags": {
"description": "Tags on an API object",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"#Operation_Object.tags"
]
},
{
"formats": [
"oas3"
],
"given": [
"#Operation_Object.tags"
]
}
]
},
"API_Server": {
"description": "API hosts defined in the API specification",
"targets": [
{
"formats": [
"oas3"
],
"given": [
"$.servers"
]
},
{
"formats": [
"oas2"
],
"given": [
"$.host"
]
}
]
},
"Response_All_Object": {
"description": "All responses (object) in an API",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.responses",
"#Operation_Responses",
"$..responses"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.components.responses",
"#Operation_Responses",
"$..responses"
]
}
]
},
"API_Server_URL": {
"description": "API host urls defined in the API specification",
"targets": [
{
"formats": [
"oas3"
],
"given": [
"$.servers[*].url"
]
},
{
"formats": [
"oas2"
],
"given": [
"$.host"
]
}
]
},
"All_Ref": {
"description": "All references throughout the API",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..[?(@property === '$ref')]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..[?(@property === '$ref')]"
]
}
]
},
"All_Enum_Object": {
"description": "All references throughout the API",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..[?(@ && @.enum && @.type)]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..[?(@ && @.enum && @.type)]"
]
}
]
},
"Request_Parameter_All": {
"description": "All request parameters",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..parameters[*]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..parameters[*]"
]
}
]
},
"Request_Parameter_Query": {
"description": "All request query parameters",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..parameters[?(@.in==\"query\")]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..parameters[?(@.in==\"query\")]"
]
}
]
},
"Request_Parameter_Header": {
"description": "All request header parameters",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..parameters[?(@.in==\"header\")]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..parameters[?(@.in==\"header\")]"
]
}
]
},
"Request_Parameter_Cookie": {
"description": "All request cookie parameters",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..parameters[?(@.in==\"cookie\")]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..parameters[?(@.in==\"cookie\")]"
]
}
]
},
"Request_Parameter_Path": {
"description": "All request path parameters",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..parameters[?(@.in==\"path\")]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..parameters[?(@.in==\"path\")]"
]
}
]
},
"Path_Object": {
"description": "Path object. Usually used to target the Path key e.g. `/users/{userId}`",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.paths"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.paths"
]
}
]
},
"All_Example_Schema": {
"description": "All examples for schemas",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..definitions..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
"$..parameters..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
"$..responses..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.components.schemas..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
"$..content..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
"$..headers..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
"$..parameters..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
]
}
]
},
"API_Document_RecursiveSearch": {
"description": "The complete API specification document. This can be used to target any part of the OpenAPI document using **field**.\n\n*Use this if you don't find specific targets that cater to your usecase.* ",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.."
]
},
{
"formats": [
"oas3"
],
"given": [
"$.."
]
}
]
},
"All_Example": {
"description": "All examples across the API document",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..examples[*]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.components.examples[*]",
"$.paths[*][*]..content[*].examples[*]",
"$.paths[*][*]..parameters[*].examples[*]",
"$.components.parameters[*].examples[*]",
"$.paths[*][*]..headers[*].examples[*]",
"$.components.headers[*].examples[*]"
]
}
]
},
"All_Example_Media": {
"description": "All examples for schemas",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..responses..[?(@ && @.schema && @.examples)]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..content..[?(@ && @.schema && (@.example !== void 0 || @.examples))]",
"$..headers..[?(@ && @.schema && (@.example !== void 0 || @.examples))]",
"$..parameters..[?(@ && @.schema && (@.example !== void 0 || @.examples))]"
]
}
]
},
"API_Tags_Item": {
"description": "Tags on an API object",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$.tags[*]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$.tags[*]"
]
}
]
},
"All_Enum_Value": {
"description": "All enum values throughout the API",
"targets": [
{
"formats": [
"oas2"
],
"given": [
"$..[?(@ && @.enum)].enum[*]"
]
},
{
"formats": [
"oas3"
],
"given": [
"$..[?(@ && @.enum)].enum[*]"
]
}
]
}
},
"rules": {
"contact-url": {
"given": [
"#API_Contact"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "url"
},
"description": "The `contact` object should have a valid organization URL. \r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"contact\": {\r\n ... ,\r\n \"url\": \"https://acme.com\",\r\n ... \r\n},\r\n```",
"message": "Contact object should have \"url\"."
},
"contact-email": {
"given": [
"#API_Contact"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "email"
},
"description": "The `contact` object should have a valid email. \r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"contact\": {\r\n ... ,\r\n ... ,\r\n \"email\": \"[email protected]\"\r\n},\r\n```",
"message": "Contact object should have \"email\""
},
"info-contact": {
"given": [
"#API_Document"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "info.contact"
},
"description": "The `info' object should include a `contact` object.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"info\": {\r\n ... ,\r\n ... ,\r\n \"contact\": {\r\n \"name\": \"ACME Corporation\",\r\n \"url\": \"https://acme.com\",\r\n \"email\": \"[email protected]\"\r\n }\r\n } \r\n}\r\n```",
"message": "Info object should have \"contact\" object."
},
"info-description": {
"given": [
"#API_Document"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "info.description"
},
"description": "The `info` object should have a `description` object.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"info\": {\r\n ... ,\r\n ... ,\r\n \"description\": \"This describes my API.\",\r\n ... \r\n }\r\n } \r\n}\r\n```",
"message": "Info object should have \"description\" object."
},
"info-license": {
"given": [
"#API_Document"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "info.license"
},
"description": "The `info` object should have a `license` object. \r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"info\": {\r\n ... ,\r\n ... ,\r\n \"license\": {\r\n \"name\": \"Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)\",\r\n \"url\": \"https://creativecommons.org/licenses/by-sa/4.0/\"\r\n }\r\n } \r\n}\r\n```",
"message": "Info object should have \"license\" object."
},
"license-url": {
"given": [
"#API_License"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "url"
},
"description": "The `license` object should include a valid url.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"license\": {\r\n \"name\": \"Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)\",\r\n \"url\": \"https://creativecommons.org/licenses/by-sa/4.0/\"\r\n }\r\n}\r\n```",
"message": "License object should include \"url\"."
},
"no-eval-in-markdown": {
"given": [
"#All_Markdown"
],
"severity": "warn",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "eval\\("
}
},
"description": "Markdown descriptions should not contain [`eval()` functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval), which pose a security risk. \r\n\r\n**Invalid Example**\r\n\r\n```json lineNumbers\r\n{ \r\n \"info\": {\r\n ... ,\r\n ... , \r\n \"description\": \"API for users. eval()\"",
"message": "Markdown descriptions must not have \"eval(\"."
},
"no-script-tags-in-markdown": {
"given": [
"#All_Markdown"
],
"severity": "warn",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "<script"
}
},
"description": "Markdown descriptions should not contain `script` tags, which pose a security risk. \r\n\r\n**Invalid Example**\r\n\r\n```json lineNumbers\r\n{ \r\n \"info\": {\r\n ... ,\r\n ... , \r\n \"description\": \"API for users. <script>alert(\"You are Hacked\");</script>',\"\r\n```",
"message": "Markdown descriptions must not have \"<script>\" tags."
},
"openapi-tags-alphabetical": {
"given": [
"#API_Tags"
],
"severity": "warn",
"then": {
"function": "alphabetical",
"functionOptions": {
"keyedBy": "name"
}
},
"description": "Global tags specified at the root OpenAPI Document level should be in alphabetical order based on the `name` property.\r\n\r\n**Invalid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"tags\":[\r\n {\r\n \"name\":\"Z Global Tag\"\r\n },\r\n {\r\n \"name\":\"A Global Tag\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"tags\":[\r\n {\r\n \"name\":\"A Global Tag\"\r\n },\r\n {\r\n \"name\":\"Z Global Tag\"\r\n }\r\n ]\r\n}\r\n```",
"message": "OpenAPI object should have alphabetical \"tags\"."
},
"openapi-tags": {
"given": [
"#API_Tags"
],
"severity": "warn",
"then": {
"function": "schema",
"functionOptions": {
"schema": {
"type": "array",
"minItems": 1
}
}
},
"description": "At least one global tag should be specified at the root OpenAPI Document level.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"tags\":[\r\n {\r\n \"name\":\"Global Tag #1\"\r\n },\r\n {\r\n \"name\":\"Global Tag #2\"\r\n }\r\n ]\r\n}\r\n```",
"message": "OpenAPI object should have non-empty \"tags\" array."
},
"operation-description": {
"given": [
"#Operation_Object"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "description"
},
"description": "Each operation should have a description. \r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n ... ,\r\n \"description\": \"Get a list of users.\",\r\n ... ,\r\n ... ,\r\n }\r\n}\r\n```",
"message": "Operation \"description\" should be present and non-empty string."
},
"operation-operationId": {
"given": [
"#Operation_Object"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "operationId"
},
"description": "All operations should have an `operationId`.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n \"summary\": \"Get users\",\r\n ... ,\r\n \"operationId\": \"get-users\"\r\n }\r\n}\r\n```",
"message": "Operation should have \"operationId\"."
},
"operation-operationId-valid-in-url": {
"given": [
"#Operation_Object"
],
"severity": "error",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^[A-Za-z0-9-._~:/?#\\[\\]@!\\$&'()*+,;=]*$"
},
"field": "operationId"
},
"description": "Operation IDs must not contain characters that are invalid for URLs. \r\n\r\n**Invalid Example**\r\n\r\nThe `operationId` in this example includes a pipe and space, which are invalid for URLs.\r\n\r\n```json lineNumbers\r\n{\r\n \"/users\": {\r\n \"get\": {\r\n ... ,\r\n \"operationId\": \"invalid|operationID \",\r\n ... ,\r\n }\r\n }\r\n}\r\n```\r\n\r\n**Valid Example**\r\n\r\nThis `operationId` is valid for URLs.\r\n\r\n```json lineNumbers\r\n{\r\n \"/users\": {\r\n \"get\": {\r\n ... ,\r\n \"operationId\": \"this-must-be-unique\",\r\n ... ,\r\n }\r\n }\r\n}\r\n```",
"message": "OperationId should not have characters that are invalid when used in URL."
},
"operation-singular-tag": {
"given": [
"#API_Tags"
],
"severity": "off",
"then": {
"function": "length",
"functionOptions": {
"max": 1
}
},
"description": "Operation should not have more than a single tag.",
"message": "Operation should not have more than a single tag."
},
"operation-tags": {
"given": [
"#Operation_Object"
],
"severity": "warn",
"then": {
"function": "length",
"functionOptions": {
"max": 999,
"min": 1
},
"field": "tags"
},
"description": "At least one tag should be defined for each operation.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n ... ,\r\n ... ,\r\n \"tags\": [\r\n \"Users\"\r\n ],\r\n }\r\n}",
"message": "Operation should have non-empty \"tags\" array."
},
"path-declarations-must-exist": {
"given": [
"#Path_Item"
],
"severity": "error",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "{}"
},
"field": "@key"
},
"description": "Path parameter declarations must not be empty.\r\n\r\n**Invalid Example**\r\n\r\n`/users/{}`\r\n\r\n**Valid Example**\r\n\r\n`/users/{userId}`",
"message": "Path parameter declarations must not be empty, ex.\"/given/{}\" is invalid."
},
"contact-name": {
"given": [
"#API_Contact"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "name"
},
"description": "The `contact` object should have an organization name. \r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"contact\": {\r\n \"name\": \"ACME Corporation\",\r\n ... ,\r\n ... \r\n},\r\n```\r\n",
"message": "Contact object should have \"name\""
},
"path-keys-no-trailing-slash": {
"given": [
"#Path_Object"
],
"severity": "warn",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": ".+\\/$"
},
"field": "@key"
},
"description": "Path keys should not end in forward slashes. This is a best practice for working with web tooling, such as mock servers, code generators, application frameworks, and more).\r\n\r\n**Invalid Example**\r\n\r\n```json\r\n{\r\n \"/users/\": {\r\n```\r\n\r\n**Valid Example**\r\n\r\n```json\r\n{\r\n \"/users\": {\r\n```",
"message": "Path should not end with slash."
},
"path-not-include-query": {
"given": [
"#Path_Object"
],
"severity": "warn",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "\\?"
},
"field": "@key"
},
"description": "Paths should not include `query` string items. Instead, add them as parameters with `in: query`.\r\n\r\n**Invalid Example**\r\n\r\n```json\r\n{\r\n \"/users/{?id}\": {\r\n\r\n```\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"parameters\": [\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"name\": \"id\",\r\n \"in\": \"path\",\r\n \"required\": true,\r\n \"description\": \"User's ID\"\r\n }\r\n ]\r\n}\r\n\r\n```",
"message": "Path should not include query string."
},
"tag-description": {
"given": [
"#API_Tags_Item"
],
"severity": "warn",
"then": {
"function": "truthy",
"field": "description"
},
"description": "Tags defined at the global level should have a description.\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"tags\": [\r\n {\r\n \"name\":\"Users\",\r\n \"description\":\"End-user information\"\r\n }\r\n ]\r\n}\r\n```",
"message": "Tag object should have \"description\"."
},
"api-servers": {
"given": [
"#API_Server"
],
"severity": "warn",
"then": {
"function": "schema",
"functionOptions": {
"schema": {
"type": "array",
"minItems": 1,
"items": {
"type": "object"
}
},
"dialect": "draft7"
}
},
"description": "A server should be defined at the root document level. This can be localhost, a development server, or a production server. \n\n**Valid OpenAPI V3 Example**\n\n```json\n{\n \"servers\": [\n {\n \"url\": \"https://staging.myprodserver.com/v1\",\n \"description\": \"Staging server\"\n },\n {\n \"url\": \"https://myprodserver.com/v1\",\n \"description\": \"Production server\"\n }\n ]\n}\n```\n\n**Valid OpenAPI V2 Example**\n\n```json\n{\n \"host\": \"myprodserver.com\",\n \"basePath\": \"/v2\",\n \"schemes\": [\n \"https\"\n ]\n}\n```\n\n",
"message": "Server should be present."
},
"server-trailing-slash": {
"given": [
"#API_Server_URL"
],
"severity": "warn",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "/$"
}
},
"description": "Server URLs should not end in forward slashes. This is a best practice for working with web tooling, such as mock servers, code generators, application frameworks, and more).\r\n\r\n**Invalid Example**\r\n\r\n```json lineNumbers\r\n{ \r\n \"servers\": [\r\n {\r\n ... ,\r\n \"url\": \"https://api.openweathermap.org/data/2.5/\"\r\n }\r\n ]\r\n}\r\n```\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{ \r\n \"servers\": [\r\n {\r\n ... ,\r\n \"url\": \"https://api.openweathermap.org/data/2.5\"\r\n }\r\n ]\r\n}\r\n```",
"message": "Server URL should not have trailing slash"
},
"operation-success-response": {
"given": [
"#Operation_Object"
],
"severity": "warn",
"then": {
"function": "oasOpSuccessResponse",
"field": "responses"
},
"description": "Operations should have at least one \"2xx\" or \"3xx\" response defined.\r\n\r\n**Invalid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n ... ,\r\n \"responses\": {},\r\n }\r\n}\r\n```\r\n\r\n**Valid Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n ... ,\r\n \"responses\": {\r\n \"200\": {\r\n \"description\": \"OK\"\r\n }\r\n },\r\n }\r\n}\r\n```",
"message": "Operation should have at least one \"2xx\" or \"3xx\" response."
},
"path-params": {
"given": [
"#API_Document"
],
"severity": "error",
"then": {
"function": "oasPathParam"
},
"description": "Path parameters must be defined and valid in either the `path-parameters` or the `operation-parameters` object. Likewise, defined `path-parameters` or `operation-parameters` must be used in the `paths` string.\r\n\r\n**Valid Example**\r\n\r\nFor this path:\r\n\r\n`/users/{id}/{location}`\r\n\r\nThe following path parameters must be defined.\r\n\r\n```json lineNumbers\r\n \"parameters\": [\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"name\": \"id\",\r\n \"in\": \"path\",\r\n \"required\": true,\r\n \"description\": \"This is the user's ID\"\r\n },\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"name\": \"location\",\r\n \"in\": \"path\",\r\n \"required\": true,\r\n \"description\": \"This is the user's location\"\r\n }\r\n ]\r\n }\r\n },\r\n ```",
"message": "{{error}}"
},
"operation-parameters": {
"given": [
"#Operation_Object"
],
"severity": "warn",
"then": {
"function": "oasOpParams",
"field": "parameters"
},
"description": "Operation parameters should be unique and non-repeating:\r\n\r\n* `name` and `in` must be unique\r\n\r\nFor OAS2:\r\n\r\n* Operations should not have `in: body` and `in: formData` parameters.\r\n* Operations should have only one `in: body` parameter.\r\n\r\n**Invalid Example**\r\n\r\nIn this example, the query paramater `\"name\": \"last name\"` is repeated.\r\n\r\n```json lineNumbers\r\n{\r\n \"parameters\": [\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"in\": \"query\",\r\n \"name\": \"last name\",\r\n \"description\": \"User's last name\"\r\n },\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"in\": \"query\",\r\n \"name\": \"last name\",\r\n \"description\": \"User's last name\"\r\n }\r\n ],\r\n}\r\n```\r\n\r\n**Valid Example**\r\n\r\nIn this example, query parameters are unique.\r\n\r\n```json lineNumbers\r\n{\r\n \"parameters\": [\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"in\": \"query\",\r\n \"name\": \"first name\",\r\n \"description\": \"User's first name\"\r\n },\r\n {\r\n \"schema\": {\r\n \"type\": \"string\"\r\n },\r\n \"in\": \"query\",\r\n \"name\": \"last name\",\r\n \"description\": \"User's last name\"\r\n }\r\n ],\r\n}\r\n```",
"message": "Operation parameters are unique and non-repeating."
},
"typed-enum": {
"given": [
"#All_Enum_Object"
],
"severity": "warn",
"then": {
"function": "typedEnum"
},
"description": "All `enum' values should respect the specified type.\r\n\r\n**Invalid Example**\r\n\r\nIn this example, the `enum` type is `integer`, but the values are strings.\r\n\r\n```json lineNumbers\r\n{\r\n \"schema\": {\r\n \"type\": \"integer\",\r\n \"enum\": [\r\n \"standard\",\r\n \"metric\",\r\n \"imperial\"\r\n ]\r\n },\r\n```\r\n\r\n**Valid Example**\r\n\r\nIn this example, the `enum` type is `string` and the values are strings.\r\n\r\n```json lineNumbers\r\n{\r\n \"schema\": {\r\n \"type\": \"string\",\r\n \"enum\": [\r\n \"standard\",\r\n \"metric\",\r\n \"imperial\"\r\n ]\r\n },",
"message": "{{error}}"
},
"oas2-schema": {
"given": [
"#API_Document"
],
"severity": "error",
"then": {
"function": "oasDocumentSchema"
},
"description": "This Stoplight core rule validates the structure of OpenAPI v2 specification. This rule should never be disabled.",
"message": "{{error}}",
"formats": [
"oas2"
]
},
"oas3-schema": {
"given": [
"#API_Document"
],
"severity": "error",
"then": {
"function": "oasDocumentSchema"
},
"description": "This Stoplight core rule validates the structure of OpenAPI v3.x specification. This rule should never be disabled.",
"message": "{{error}}",
"formats": [
"oas3"
]
},
"oas3-unused-component": {
"given": [
"#API_Document"
],
"severity": "warn",
"then": {
"function": "oasUnusedComponent"
},
"description": "A potentially shareable component is not being used. This may be expected, but you should review sharable components to avoid duplicate entry.",
"message": "{{error}}",
"formats": [
"oas3"
]
},
"operation-operationId-unique": {
"given": [
"#API_Document"
],
"severity": "error",
"then": {
"function": "oasOpIdUnique"
},
"description": "Every operation in a single document must have a unique `operationID`.\r\n\r\n**Valid Example**\r\n\r\nIn this example, the `operationId` is `get-users`. This `operationId` must be unique in an API document.\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n \"summary\": \"Get users\",\r\n ... ,\r\n \"operationId\": \"get-users\"\r\n }\r\n}\r\n```\r\n",
"message": "Every operation must have unique operationId"
},
"oas2-operation-formData-consume-check": {
"given": [
"#Operation_Object"
],
"severity": "error",
"then": {
"function": "oasOpFormDataConsumeCheck"
},
"description": "Operations with an `in: formData` parameter must include a `consumes` property with one of these values:\r\n\r\n`application/x-www-form-urlencoded`\r\n\r\n`multipart/form-data`\r\n\r\n**Valid Example**\r\n\r\nIn this example, the `consumes` property correctly includes the `multipart/form-data` value.\r\n\r\n```json lineNumbers\r\n{\r\n \"post\":{\r\n \"summary\":\"Uploads a file\",\r\n \"consumes\":[\r\n \"multipart/form-data\"\r\n ],\r\n \"parameters\":[\r\n {\r\n \"name\":\"name\",\r\n \"in\":\"formData\",\r\n \"description\":\"Upload a file\",\r\n \"required\":false,\r\n \"type\":\"string\"\r\n }\r\n ]\r\n }\r\n}",
"message": "Operations with \"in: formData\" parameter must include \"application/x-www-form-urlencoded\" or \"multipart/form-data\" in their \"consumes\" property.",
"formats": [
"oas2"
]
},
"operation-tag-defined": {
"given": [
"#API_Document"
],
"severity": "warn",
"then": {
"function": "oasTagDefined"
},
"description": "Tags defined at the operation level should also be defined at the global level. \r\n\r\n**Operation-level Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"get\": {\r\n ... ,\r\n ... ,\r\n \"tags\": [\r\n \"Users\"\r\n ],\r\n }\r\n} \r\n```\r\n\r\n**Global-level Example**\r\n\r\n```json lineNumbers\r\n{\r\n \"tags\": [\r\n {\r\n \"name\": \"Users\",\r\n ... ,\r\n }\r\n ],\r\n}\r\n\r\n```",
"message": "Operation tags must be defined in global tags"