-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiled-ruleset.ts
More file actions
7533 lines (7531 loc) · 281 KB
/
Copy pathcompiled-ruleset.ts
File metadata and controls
7533 lines (7531 loc) · 281 KB
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
/* GENERATED by tools/compile-rules.mjs — do not edit. */
import * as builtins from '@stoplight/spectral-functions';
import f0 from './functions/baloise/assert-http-codes-for-operation.js';
import f1 from './functions/baloise/validate-tracing.js';
import f2 from './functions/digitalocean/ensurePropertiesExample.js';
import f3 from './functions/digitalocean/ensureAllArraysHaveItemTypes.js';
import f4 from './functions/digitalocean/ensureSnakeCaseWithDigits.js';
import f5 from './functions/digitalocean/ensureSchemaHasType.js';
import f6 from './functions/microcks/oas-verify-mocks.js';
import f7 from './functions/microcks/aas-verify-mocks.js';
import f8 from './functions/trimble/valid-url-checker.js';
import f9 from './functions/trimble/valid-version-checker.js';
import f10 from './functions/trimble/no-http-verbs-in-path.js';
import f11 from './functions/trimble/check-if-application-or-json-in-put-and-post-response.js';
import f12 from './functions/trimble/check-if-response-body-json-in-get-response.js';
import f13 from './functions/trimble/valid-http-response.js';
import f14 from './functions/trimble/check-for-query-parameter-in-every-path.js';
import f15 from './functions/trimble/does-spec-contains-valid-http-verbs.js';
import f16 from './functions/trimble/is-valid-spec.js';
import f17 from './functions/trimble/operation-summary-description.js';
import f18 from './functions/trimble/operation-post-201-202-status-code.js';
import f19 from './functions/trimble/check-content-type-for-206-get-response-code.js';
import f20 from './functions/trimble/check-standard-for-error-payload.js';
import f21 from './functions/trimble/check-description-for-all-error-responses.js';
import f22 from './functions/trimble/check-description-for-all-success-responses.js';
import f23 from './functions/trimble/check-for-content-type-in-put-and-post-responses.js';
import f24 from './functions/trimble/check-for-path-parameter.js';
import f25 from './functions/trimble/check-for-response-in-every-request.js';
import f26 from './functions/trimble/delete-must-not-return-body.js';
import f27 from './functions/trimble/invalid-symbol-in-path.js';
export const functions: Record<string, unknown> = {
...builtins,
"baloise:assert-http-codes-for-operation": f0,
"baloise:validate-tracing": f1,
"digitalocean:ensurePropertiesExample": f2,
"digitalocean:ensureAllArraysHaveItemTypes": f3,
"digitalocean:ensureSnakeCaseWithDigits": f4,
"digitalocean:ensureSchemaHasType": f5,
"microcks:oas-verify-mocks": f6,
"microcks:aas-verify-mocks": f7,
"trimble:valid-url-checker": f8,
"trimble:valid-version-checker": f9,
"trimble:no-http-verbs-in-path": f10,
"trimble:check-if-application-or-json-in-put-and-post-response": f11,
"trimble:check-if-response-body-json-in-get-response": f12,
"trimble:valid-http-response": f13,
"trimble:check-for-query-parameter-in-every-path": f14,
"trimble:does-spec-contains-valid-http-verbs": f15,
"trimble:is-valid-spec": f16,
"trimble:operation-summary-description": f17,
"trimble:operation-post-201-202-status-code": f18,
"trimble:check-content-type-for-206-get-response-code": f19,
"trimble:check-standard-for-error-payload": f20,
"trimble:check-description-for-all-error-responses": f21,
"trimble:check-description-for-all-success-responses": f22,
"trimble:check-for-content-type-in-put-and-post-responses": f23,
"trimble:check-for-path-parameter": f24,
"trimble:check-for-response-in-every-request": f25,
"trimble:delete-must-not-return-body": f26,
"trimble:invalid-symbol-in-path": f27,
};
export const ruleset = {
"description": "Spotlight best-of-breed API governance ruleset, compiled from public Spectral rulesets. Select rules with tags (source:*, category:*, format:*).",
"documentationUrl": "https://github.com/api-commons/api-validator",
"extends": [
[
"spectral:oas",
"recommended"
]
],
"rules": {
"path-segments-kebab-case": {
"description": "All YAML/JSON paths MUST follow kebab-case. It requires the targeted value to match the pattern `^/([a-z0-9]+(-[a-z0-9]+)*)?(/[a-z0-9]+(-[a-z0-9]+)*|/{.+})*$` (evaluated at `$.paths[*]~`). Severity: warn.",
"severity": "warn",
"recommended": true,
"message": "{{property}} is not kebab-case: {{error}}",
"given": "$.paths[*]~",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^/([a-z0-9]+(-[a-z0-9]+)*)?(/[a-z0-9]+(-[a-z0-9]+)*|/{.+})*$"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"experience:naming",
"experience:consistency"
]
},
"path-parameters-camel-case": {
"description": "Path parameters MUST follow camelCase. It requires the targeted value to match the pattern `^[a-z][a-zA-Z0-9]+$` (evaluated at `$..parameters[?(@.in == 'path')].name`). Severity: warn.",
"severity": "warn",
"recommended": true,
"message": "{{property}} path parameter is not camelCase: {{error}}",
"given": "$..parameters[?(@.in == 'path')].name",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^[a-z][a-zA-Z0-9]+$"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:parameters",
"experience:naming",
"experience:consistency"
]
},
"schema-definitions-camel-case": {
"description": "All YAML/JSON definitions MUST follow fields-camelCase and be ASCII alphanumeric characters or `_` or `$`. It requires the targeted value to match the pattern `/^[a-z$_]{1}[A-Z09$_]*/` (evaluated at `$.definitions[*]~`). Severity: error.",
"severity": "error",
"recommended": true,
"message": "{{property}} MUST follow camelCase and be ASCII alphanumeric characters or `_` or `$`.",
"given": "$.definitions[*]~",
"then": {
"function": "pattern",
"functionOptions": {
"match": "/^[a-z$_]{1}[A-Z09$_]*/"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:document",
"experience:naming",
"experience:consistency"
]
},
"schema-properties-camel-case": {
"description": "All JSON Schema properties MUST follow fields-camelCase and be ASCII alphanumeric characters or `_` or `$`. It requires the targeted value to match the pattern `/^[a-z$_]{1}[A-Z09$_]*/` (evaluated at `$.definitions..properties[*]~`). Severity: error.",
"severity": "error",
"recommended": true,
"message": "{{property}} MUST follow camelCase and be ASCII alphanumeric characters or `_` or `$`.",
"given": "$.definitions..properties[*]~",
"then": {
"function": "pattern",
"functionOptions": {
"match": "/^[a-z$_]{1}[A-Z09$_]*/"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:schemas",
"experience:naming",
"experience:consistency"
]
},
"header-names-hyphenated-pascal-case": {
"description": "All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation. It requires the targeted value to match the pattern `/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/` (evaluated at `$..parameters[?(@.in == 'header')].name`). Severity: error.",
"severity": "error",
"given": "$..parameters[?(@.in == 'header')].name",
"message": "'HTTP' headers MUST follow 'Hyphenated-Pascal-Case' notation",
"recommended": true,
"type": "style",
"then": {
"function": "pattern",
"functionOptions": {
"match": "/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:parameters",
"spec:headers",
"experience:naming",
"experience:consistency",
"source:sps-commerce"
]
},
"request-support-json-media-type": {
"description": "Every request MUST support `application/json` media type. It requires the targeted value to be absent or empty (evaluated at `$.paths.[*].requestBody.content[?(@property.indexOf('json') === -1)]^`). Severity: error.",
"formats": [
"oas3"
],
"recommended": true,
"severity": "error",
"message": "{{description}}: {{error}}",
"given": "$.paths.[*].requestBody.content[?(@property.indexOf('json') === -1)]^",
"then": {
"function": "falsy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:request-body",
"spec:media-types",
"experience:consistency",
"experience:usability"
]
},
"require-https-servers": {
"description": "ALL requests MUST go through `https` protocol only. It requires the targeted value to match the pattern `/^https:/` (evaluated at `$.servers..url`). Severity: error.",
"formats": [
"oas3"
],
"recommended": true,
"severity": "error",
"message": "Servers MUST be https and no other protocol is allowed.",
"given": "$.servers..url",
"then": {
"function": "pattern",
"functionOptions": {
"match": "/^https:/"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:servers",
"experience:security"
]
},
"success-response-use-hal-json": {
"description": "All success responses MUST be of media type `application/hal+json`. It requires the targeted value to be one of [\"application/hal+json\"] (evaluated at `$.paths..responses[?( @property >= 201 && @property < 300 && @property != 204)].content[*]~`). Severity: error.",
"severity": "error",
"given": "$.paths..responses[?( @property >= 201 && @property < 300 && @property != 204)].content[*]~",
"recommended": true,
"formats": [
"oas3"
],
"message": "Response documents MUST be of application/hal+json media types: {{error}}",
"then": {
"function": "enumeration",
"functionOptions": {
"values": [
"application/hal+json"
]
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:responses",
"spec:media-types",
"experience:consistency",
"experience:data-modeling"
]
},
"ok-response-use-hal-or-problem-json": {
"description": "All success responses MUST be of media type `application/hal+json` or `application/problem+json`. It requires the targeted value to be one of [\"application/hal+json\",\"application/problem+json\"] (evaluated at `$.paths..responses[?( @property == 200 )].content[*]~`). Severity: error.",
"severity": "error",
"given": "$.paths..responses[?( @property == 200 )].content[*]~",
"recommended": true,
"formats": [
"oas3"
],
"message": "Response documents MUST be of application/hal+json or application/problem+json media types: {{error}}",
"then": {
"function": "enumeration",
"functionOptions": {
"values": [
"application/hal+json",
"application/problem+json"
]
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:responses",
"spec:media-types",
"experience:consistency",
"experience:data-modeling"
]
},
"success-response-match-hal-schema": {
"description": "All success responses MUST follow `application/hal+json` schema. It validates the `schema` field against a JSON Schema (evaluated at `$.paths..responses[?( @property == 200 && @property < 300 && @property != 204)].content[?(@property === \"application/hal+json\")]`). Severity: error.",
"severity": "error",
"given": "$.paths..responses[?( @property == 200 && @property < 300 && @property != 204)].content[?(@property === \"application/hal+json\")]",
"recommended": true,
"type": "style",
"formats": [
"oas3"
],
"message": "Response documents MUST follow application/hal+json schema: {{error}}",
"then": {
"field": "schema",
"function": "schema",
"functionOptions": {
"schema": {
"$ref": "./supermodel/adidas/api/HAL.yaml"
}
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:responses",
"spec:media-types",
"experience:data-modeling",
"experience:consistency"
]
},
"get-no-request-body": {
"description": "GET requests MUST NOT have a request body. It requires the targeted value to be absent or empty (evaluated at `$.paths[*].get.requestBody`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"given": "$.paths[*].get.requestBody",
"then": {
"function": "falsy",
"message": "{{description}}: {{error}}"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:operations",
"spec:request-body",
"experience:consistency",
"experience:usability"
]
},
"post-not-for-retrieval": {
"description": "POST requests SHOULD NOT be used for retrieving information. Use GET instead. It requires the `summary` field not to match `(retrieve|fetch|get|read)` (evaluated at `$.paths[*].post`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"given": "$.paths[*].post",
"then": {
"field": "summary",
"function": "pattern",
"functionOptions": {
"notMatch": "(retrieve|fetch|get|read)"
},
"message": "{{description}}: {{error}}"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:operations",
"experience:consistency",
"experience:usability"
]
},
"put-require-request-body": {
"description": "PUT requests MUST have a request body. It requires the `requestBody` field to be present and non-empty (evaluated at `$.paths[*].put`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"given": "$.paths[*].put",
"then": {
"field": "requestBody",
"function": "truthy",
"message": "{{description}}: {{error}}"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:operations",
"experience:consistency",
"experience:usability"
]
},
"delete-no-request-body": {
"description": "DELETE requests MUST NOT have a request body. It requires the targeted value to be absent or empty (evaluated at `$.paths[*].delete.requestBody`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"given": "$.paths[*].delete.requestBody",
"then": {
"function": "falsy",
"message": "{{description}}: {{error}}"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:operations",
"spec:request-body",
"experience:consistency",
"experience:usability"
]
},
"paths-no-verbs": {
"description": "API paths MUST be resource-focused and MUST NOT include verbs like 'get', 'update', 'create', or 'delete'. It requires the targeted value not to match `/\\b(get|update|create|delete|fetch|retrieve)\\b/` (evaluated at `$.paths[*]~`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"message": "Path '{{path}}' includes a verb (e.g., 'get', 'update', 'create', 'delete'). API paths SHOULD be resource-focused.",
"given": "$.paths[*]~",
"then": {
"function": "pattern",
"functionOptions": {
"notMatch": "/\\b(get|update|create|delete|fetch|retrieve)\\b/"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"experience:naming",
"experience:consistency"
]
},
"require-realistic-examples": {
"description": "API design SHOULD include real-like examples for request and response definitions. It requires the `example` field to be present and non-empty (evaluated at `$..[?(@.example || @.examples)]`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"message": "The {{property}} SHOULD include a real-like example. Add realistic examples to improve API usability.",
"given": "$..[?(@.example || @.examples)]",
"then": {
"field": "example",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:examples",
"experience:documentation",
"experience:usability"
]
},
"version-semantic-and-stable": {
"description": "The API contract MUST have a stable version and MUST follow semantic versioning (e.g., '1.0.0'). Words like 'SNAPSHOT' or 'RELEASE' are not allowed. It requires the targeted value to match the pattern `^(?!.*\\b(SNAPSHOT|RELEASE)\\b)(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$` (evaluated at `$.info.version`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.info.version",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^(?!.*\\b(SNAPSHOT|RELEASE)\\b)(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:info",
"experience:versioning",
"experience:consistency"
]
},
"require-root-security": {
"description": "The API contract MUST include a 'security' section at the root level. It requires the `security` field to be present and non-empty (evaluated at `$`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$",
"then": {
"field": "security",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:document",
"experience:security",
"experience:governance"
]
},
"require-components-section": {
"description": "The API contract MUST include a 'components' section. It requires the `components` field to be present and non-empty (evaluated at `$`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$",
"then": {
"field": "components",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:document",
"experience:consistency",
"experience:governance"
]
},
"require-security-schemes": {
"description": "The API contract MUST include a 'securitySchemes' subsection under the 'components' section. It requires the `securitySchemes` field to be present and non-empty (evaluated at `$.components`). Severity: error.",
"severity": "error",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.components",
"then": {
"field": "securitySchemes",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:components",
"experience:security",
"experience:governance",
"source:api-evangelist"
]
},
"info-require-leanix-id": {
"description": "The API contract SHOULD include a custom field 'x-leanixid' in the 'info' section. It requires the `x-leanixid` field to be present and non-empty (evaluated at `$.info`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.info",
"then": {
"field": "x-leanixid",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:info",
"experience:governance",
"experience:discoverability"
]
},
"leanix-id-valid-uuid": {
"description": "The API contract SHOULD include a custom field 'x-leanixid' containing a valid UUID. It requires the targeted value to match the pattern `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$` (evaluated at `$.info.x-leanixid`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.info.x-leanixid",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:info",
"experience:governance",
"experience:consistency"
]
},
"info-require-gateway": {
"description": "The API contract SHOULD include a custom field 'x-gateway' in the 'info' section. It requires the `x-gateway` field to be present and non-empty (evaluated at `$.info`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.info",
"then": {
"field": "x-gateway",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:info",
"experience:governance"
]
},
"gateway-from-allowed-list": {
"description": "The 'x-gateway' property, if present, MUST have a value in the enumeration: kong, nginx, aws, akamai, sap, other. It requires the `x-gateway` field to be one of [\"kong\",\"nginx\",\"aws\",\"akamai\",\"sap\",\"other\"] (evaluated at `$`). Severity: warn.",
"severity": "warn",
"recommended": true,
"formats": [
"oas3"
],
"given": "$",
"then": {
"field": "x-gateway",
"function": "enumeration",
"functionOptions": {
"values": [
"kong",
"nginx",
"aws",
"akamai",
"sap",
"other"
]
}
},
"tags": [
"source:adidas",
"format:openapi",
"spec:document",
"experience:governance",
"experience:consistency"
]
},
"responses-include-hypermedia-links": {
"description": "The API contract MAY include hypermedia links to represent the state of resources and be navigable. It requires the `links` field to be present and non-empty (evaluated at `$.paths[*][*].responses[*]`). Severity: hint.",
"severity": "hint",
"recommended": true,
"formats": [
"oas3"
],
"message": "{{description}}: {{error}}",
"given": "$.paths[*][*].responses[*]",
"then": {
"field": "links",
"function": "truthy"
},
"tags": [
"source:adidas",
"format:openapi",
"spec:paths",
"spec:responses",
"experience:discoverability",
"experience:usability"
]
},
"uri-versioning-single-version": {
"message": "Path can contain correct URI versioning",
"description": "CAN use correct URI versioning [115a]. It requires the targeted value to match the pattern `^((?!.*\\/v\\d+(\\/.*)?\\/v\\d+)\\/.*)$` (evaluated at `$.paths.*~`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/can-use-correct-URI-versioning.test.md",
"severity": "error",
"given": "$.paths.*~",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^((?!.*\\/v\\d+(\\/.*)?\\/v\\d+)\\/.*)$"
}
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"experience:versioning",
"experience:consistency"
]
},
"property-names-camel-case": {
"message": "Property name has to be ASCII camelCase",
"description": "MUST property names must be ASCII camelCase [118a]. It requires the targeted value to match the pattern `^[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$` (evaluated at `$.paths.*.*[responses,requestBody]..content..schema..properties.*~`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/property-names-must-be-ascii-camel-case.md",
"severity": "error",
"given": "$.paths.*.*[responses,requestBody]..content..schema..properties.*~",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$"
}
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"spec:request-body",
"spec:responses",
"spec:media-types",
"spec:schemas",
"experience:naming",
"experience:consistency"
]
},
"use-standard-status-codes": {
"message": "{{property}} is not a standardized response code",
"description": "MUST use standard HTTP status codes [150a]. It requires the targeted value to be one of [\"100\",\"101\",\"200\",\"201\",\"202\",\"203\",\"204\",\"205\",\"206\",\"207\",\"300\",\"301\",\"302\",\"303\",\"304\",\"305\",\"307\",\"400\",\"401\",\"402\",\"403\",\"404\",\"405\",\"406\",\"407\",\"408\",\"409\",\"410\",\"411\",\"412\",\"413\",\"414\",\"415\",\"416\",\"417\",\"422\",\"423\",\"426\",\"428\",\"429\",\"431\",\"500\",\"501\",\"502\",\"503\",\"504\",\"505\",\"511\",\"default\"] (evaluated at `$.paths.*.*.responses.*~`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/must-use-additional-standard-http-status-codes.md",
"severity": "error",
"given": "$.paths.*.*.responses.*~",
"then": {
"function": "enumeration",
"functionOptions": {
"values": [
"100",
"101",
"200",
"201",
"202",
"203",
"204",
"205",
"206",
"207",
"300",
"301",
"302",
"303",
"304",
"305",
"307",
"400",
"401",
"402",
"403",
"404",
"405",
"406",
"407",
"408",
"409",
"410",
"411",
"412",
"413",
"414",
"415",
"416",
"417",
"422",
"423",
"426",
"428",
"429",
"431",
"500",
"501",
"502",
"503",
"504",
"505",
"511",
"default"
]
}
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"spec:responses",
"experience:error-handling",
"experience:consistency"
]
},
"prefer-400-over-422": {
"message": "Prefer 400 over 422 as response code",
"description": "MUST use standard HTTP status codes [150a]. It requires the `422` field to be defined (evaluated at `$.paths.*.*.responses.422`). Severity: warn.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/must-use-additional-standard-http-status-codes.md",
"severity": "warn",
"given": "$.paths.*.*.responses.422",
"then": {
"field": "422",
"function": "defined"
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"spec:responses",
"experience:error-handling",
"experience:consistency"
]
},
"operation-well-understood-status-codes": {
"message": "{{error}}",
"description": "MUST use standard HTTP status codes [150]. It applies a custom validation to the targeted value (evaluated at `$.paths.*`). Severity: warn.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/should-use-additional-well-understood-http-status-codes.md",
"severity": "warn",
"given": "$.paths.*",
"then": {
"function": "baloise:assert-http-codes-for-operation",
"functionOptions": {
"wellUnderstood": {
"200": [
"ALL"
],
"201": [
"POST",
"PUT"
],
"202": [
"POST",
"PUT",
"DELETE",
"PATCH"
],
"204": [
"PUT",
"DELETE",
"PATCH"
],
"207": [
"POST"
],
"301": [
"ALL"
],
"303": [
"PATCH",
"POST",
"PUT",
"DELETE"
],
"304": [
"GET",
"HEAD"
],
"400": [
"ALL"
],
"401": [
"ALL"
],
"403": [
"ALL"
],
"404": [
"ALL"
],
"405": [
"ALL"
],
"406": [
"ALL"
],
"408": [
"ALL"
],
"409": [
"POST",
"PUT",
"DELETE",
"PATCH"
],
"410": [
"ALL"
],
"412": [
"PUT",
"DELETE",
"PATCH"
],
"415": [
"POST",
"PUT",
"DELETE",
"PATCH"
],
"422": [
"ALL"
],
"423": [
"PUT",
"DELETE",
"PATCH"
],
"428": [
"ALL"
],
"429": [
"ALL"
],
"500": [
"ALL"
],
"501": [
"ALL"
],
"503": [
"ALL"
],
"default": [
"ALL"
]
}
}
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"experience:error-handling",
"experience:consistency"
]
},
"require-tracing-headers": {
"message": "Header X-B3-Traceid, X-B3-Spanid or traceparent (w3c) missing",
"description": "MUST use b3 or w3c tracing [233a]. It applies a custom validation to the targeted value (evaluated at `$.paths.*`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/requests-must-use-tracing.md",
"severity": "error",
"given": "$.paths.*",
"then": {
"function": "baloise:validate-tracing"
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"experience:reliability",
"experience:governance"
]
},
"info-require-audience": {
"message": "Missing or wrong `info.x-audience`.",
"description": "MUST provide API audience [219]. It requires the `x-audience` field to be present and non-empty, and requires the `x-audience` field to match the pattern `^(team-internal|domain-internal|company-internal|external-partner|external-public)$` (evaluated at `$.info`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/property-names-must-be-ascii-camel-case.md",
"severity": "error",
"given": "$.info",
"then": [
{
"field": "x-audience",
"function": "truthy"
},
{
"field": "x-audience",
"function": "pattern",
"functionOptions": {
"match": "^(team-internal|domain-internal|company-internal|external-partner|external-public)$"
}
}
],
"tags": [
"source:baloise",
"format:openapi",
"spec:info",
"experience:governance",
"experience:discoverability"
]
},
"query-parameters-camel-case": {
"message": "Query parameter name has to be ASCII camelCase",
"description": "MUST query parameter names must be ASCII camelCase [130a]. It requires the targeted value to match the pattern `^[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$` (evaluated at `$.paths.*.*.parameters[?(@ && @.in=='query')].name`). Severity: error.",
"documentationUrl": "https://github.com/baloise-incubator/spectral-ruleset/blob/main/doc/rules/query-parameter-names-must-be-ascii-camel-case.md",
"severity": "error",
"given": "$.paths.*.*.parameters[?(@ && @.in=='query')].name",
"then": {
"function": "pattern",
"functionOptions": {
"match": "^[a-z]+((\\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?$"
}
},
"tags": [
"source:baloise",
"format:openapi",
"spec:paths",
"spec:parameters",
"experience:naming",
"experience:consistency"
]
},
"responses-include-ratelimit-headers": {
"description": "Response must include ratelimit-x headers. It requires the `headers.ratelimit-limit` field to be present and non-empty, and requires the `headers.ratelimit-remaining` field to be present and non-empty, and requires the `headers.ratelimit-reset` field to be present and non-empty (evaluated at `$..responses.*`). Severity: error.",
"message": "{{description}}; missing {{property}}",
"severity": "error",
"given": "$..responses.*",
"then": [
{
"field": "headers.ratelimit-limit",
"function": "truthy"
},
{
"field": "headers.ratelimit-remaining",
"function": "truthy"
},
{
"field": "headers.ratelimit-reset",
"function": "truthy"
}
],
"tags": [
"source:digitalocean",
"format:openapi",
"spec:responses",
"experience:reliability",
"experience:documentation"
]
},
"properties-require-examples": {
"description": "Object properties must include examples. It applies a custom validation to the targeted value (evaluated at `$..properties..properties.*`). Severity: error.",
"given": "$..properties..properties.*",
"severity": "error",
"message": "{{description}}; {{property}}",
"then": {
"function": "digitalocean:ensurePropertiesExample"
},
"tags": [
"source:digitalocean",