@openlint/ruleset-spectral-oas 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +11 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +8 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/oas/functions/index.d.ts +15 -0
  7. package/dist/oas/functions/index.js +33 -0
  8. package/dist/oas/functions/index.js.map +1 -0
  9. package/dist/oas/functions/oasDiscriminator.d.ts +6 -0
  10. package/dist/oas/functions/oasDiscriminator.js +39 -0
  11. package/dist/oas/functions/oasDiscriminator.js.map +1 -0
  12. package/dist/oas/functions/oasDocumentSchema.d.ts +2 -0
  13. package/dist/oas/functions/oasDocumentSchema.js +104 -0
  14. package/dist/oas/functions/oasDocumentSchema.js.map +1 -0
  15. package/dist/oas/functions/oasExample.d.ts +7 -0
  16. package/dist/oas/functions/oasExample.js +217 -0
  17. package/dist/oas/functions/oasExample.js.map +1 -0
  18. package/dist/oas/functions/oasOpFormDataConsumeCheck.d.ts +6 -0
  19. package/dist/oas/functions/oasOpFormDataConsumeCheck.js +30 -0
  20. package/dist/oas/functions/oasOpFormDataConsumeCheck.js.map +1 -0
  21. package/dist/oas/functions/oasOpIdUnique.d.ts +2 -0
  22. package/dist/oas/functions/oasOpIdUnique.js +35 -0
  23. package/dist/oas/functions/oasOpIdUnique.js.map +1 -0
  24. package/dist/oas/functions/oasOpParams.d.ts +2 -0
  25. package/dist/oas/functions/oasOpParams.js +75 -0
  26. package/dist/oas/functions/oasOpParams.js.map +1 -0
  27. package/dist/oas/functions/oasOpSuccessResponse.d.ts +2 -0
  28. package/dist/oas/functions/oasOpSuccessResponse.js +27 -0
  29. package/dist/oas/functions/oasOpSuccessResponse.js.map +1 -0
  30. package/dist/oas/functions/oasPathParam.d.ts +2 -0
  31. package/dist/oas/functions/oasPathParam.js +135 -0
  32. package/dist/oas/functions/oasPathParam.js.map +1 -0
  33. package/dist/oas/functions/oasSchema.d.ts +5 -0
  34. package/dist/oas/functions/oasSchema.js +81 -0
  35. package/dist/oas/functions/oasSchema.js.map +1 -0
  36. package/dist/oas/functions/oasSecurityDefined.d.ts +5 -0
  37. package/dist/oas/functions/oasSecurityDefined.js +76 -0
  38. package/dist/oas/functions/oasSecurityDefined.js.map +1 -0
  39. package/dist/oas/functions/oasTagDefined.d.ts +2 -0
  40. package/dist/oas/functions/oasTagDefined.js +42 -0
  41. package/dist/oas/functions/oasTagDefined.js.map +1 -0
  42. package/dist/oas/functions/oasUnusedComponent.d.ts +4 -0
  43. package/dist/oas/functions/oasUnusedComponent.js +40 -0
  44. package/dist/oas/functions/oasUnusedComponent.js.map +1 -0
  45. package/dist/oas/functions/refSiblings.d.ts +2 -0
  46. package/dist/oas/functions/refSiblings.js +42 -0
  47. package/dist/oas/functions/refSiblings.js.map +1 -0
  48. package/dist/oas/functions/typedEnum.d.ts +7 -0
  49. package/dist/oas/functions/typedEnum.js +76 -0
  50. package/dist/oas/functions/typedEnum.js.map +1 -0
  51. package/dist/oas/functions/utils/getAllOperations.d.ts +7 -0
  52. package/dist/oas/functions/utils/getAllOperations.js +31 -0
  53. package/dist/oas/functions/utils/getAllOperations.js.map +1 -0
  54. package/dist/oas/functions/utils/isObject.d.ts +2 -0
  55. package/dist/oas/functions/utils/isObject.js +7 -0
  56. package/dist/oas/functions/utils/isObject.js.map +1 -0
  57. package/dist/oas/index.d.ts +733 -0
  58. package/dist/oas/index.js +765 -0
  59. package/dist/oas/index.js.map +1 -0
  60. package/dist/oas/schemas/__fixtures__/validate.d.ts +1 -0
  61. package/dist/oas/schemas/__fixtures__/validate.js +3 -0
  62. package/dist/oas/schemas/__fixtures__/validate.js.map +1 -0
  63. package/dist/oas/schemas/json-schema/draft-04.json +137 -0
  64. package/dist/oas/schemas/json-schema/draft-2020-12/index.json +54 -0
  65. package/dist/oas/schemas/json-schema/draft-2020-12/validation.json +101 -0
  66. package/dist/oas/schemas/oas/v2.0.json +1478 -0
  67. package/dist/oas/schemas/oas/v3.0.json +1652 -0
  68. package/dist/oas/schemas/oas/v3.1/dialect.schema.json +35 -0
  69. package/dist/oas/schemas/oas/v3.1/index.json +1276 -0
  70. package/dist/oas/schemas/oas/v3.1/meta.schema.json +93 -0
  71. package/dist/oas/schemas/oas/v3.2/dialect.schema.json +25 -0
  72. package/dist/oas/schemas/oas/v3.2/index.json +1527 -0
  73. package/dist/oas/schemas/oas/v3.2/meta.schema.json +103 -0
  74. package/dist/oas/schemas/validators.d.ts +66 -0
  75. package/dist/oas/schemas/validators.js +12991 -0
  76. package/dist/oas/schemas/validators.js.map +1 -0
  77. package/dist/shared/functions/index.d.ts +2 -0
  78. package/dist/shared/functions/index.js +7 -0
  79. package/dist/shared/functions/index.js.map +1 -0
  80. package/dist/shared/functions/serverVariables/index.d.ts +16 -0
  81. package/dist/shared/functions/serverVariables/index.js +154 -0
  82. package/dist/shared/functions/serverVariables/index.js.map +1 -0
  83. package/dist/shared/functions/serverVariables/utils/applyUrlVariables.d.ts +3 -0
  84. package/dist/shared/functions/serverVariables/utils/applyUrlVariables.js +32 -0
  85. package/dist/shared/functions/serverVariables/utils/applyUrlVariables.js.map +1 -0
  86. package/dist/shared/functions/serverVariables/utils/parseUrlVariables.d.ts +1 -0
  87. package/dist/shared/functions/serverVariables/utils/parseUrlVariables.js +12 -0
  88. package/dist/shared/functions/serverVariables/utils/parseUrlVariables.js.map +1 -0
  89. package/dist/shared/functions/uniquenessTags.d.ts +5 -0
  90. package/dist/shared/functions/uniquenessTags.js +42 -0
  91. package/dist/shared/functions/uniquenessTags.js.map +1 -0
  92. package/dist/shared/utils/getMissingProps.d.ts +1 -0
  93. package/dist/shared/utils/getMissingProps.js +9 -0
  94. package/dist/shared/utils/getMissingProps.js.map +1 -0
  95. package/dist/shared/utils/getRedundantProps.d.ts +1 -0
  96. package/dist/shared/utils/getRedundantProps.js +9 -0
  97. package/dist/shared/utils/getRedundantProps.js.map +1 -0
  98. package/package.json +47 -4
@@ -0,0 +1,765 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const openlint_formats_1 = require("@openlint/openlint-formats");
6
+ const openlint_functions_1 = require("@openlint/openlint-functions");
7
+ const functions_1 = require("./functions");
8
+ const functions_2 = require("../shared/functions");
9
+ const serverVariables_1 = tslib_1.__importDefault(require("../shared/functions/serverVariables"));
10
+ const ruleset = {
11
+ documentationUrl: 'https://docs.openlint.org/reference/openapi-rules',
12
+ formats: [openlint_formats_1.oas2, openlint_formats_1.oas3, openlint_formats_1.oas3_0, openlint_formats_1.oas3_1, openlint_formats_1.oas3_2],
13
+ aliases: {
14
+ PathItem: ['$.paths[*]'],
15
+ OperationObject: ['#PathItem[get,put,post,delete,options,head,patch,trace]'],
16
+ SecurityRequirementObject: ['$.security[*]', '#OperationObject.security[*]'],
17
+ ResponseObject: {
18
+ targets: [
19
+ {
20
+ formats: [openlint_formats_1.oas2],
21
+ given: ['#OperationObject.responses[*]', '$.responses[*]'],
22
+ },
23
+ {
24
+ formats: [openlint_formats_1.oas3],
25
+ given: ['#OperationObject.responses[*]', '$.components.responses[*]'],
26
+ },
27
+ ],
28
+ },
29
+ LinkObject: {
30
+ targets: [
31
+ {
32
+ formats: [openlint_formats_1.oas3],
33
+ given: ['$.components.links[*]', '#ResponseObject.links[*]'],
34
+ },
35
+ ],
36
+ },
37
+ ArrayProperties: {
38
+ targets: [
39
+ {
40
+ formats: [openlint_formats_1.oas2, openlint_formats_1.oas3_0],
41
+ given: [
42
+ // Check for type: 'array'
43
+ '$..[?(@ && @.type=="array")]',
44
+ ],
45
+ },
46
+ {
47
+ formats: [openlint_formats_1.oas3_1, openlint_formats_1.oas3_2],
48
+ given: [
49
+ // Still check for type: 'array'
50
+ '$..[?(@ && @.type=="array")]',
51
+ // also check for type: ['array', ...]
52
+ '$..[?(@ && @.type && @.type.constructor.name === "Array" && @.type.includes("array"))]',
53
+ ],
54
+ },
55
+ ],
56
+ },
57
+ },
58
+ rules: {
59
+ 'operation-success-response': {
60
+ description: 'Operation must have at least one "2xx" or "3xx" response.',
61
+ recommended: true,
62
+ given: '#OperationObject',
63
+ then: {
64
+ field: 'responses',
65
+ function: functions_1.oasOpSuccessResponse,
66
+ },
67
+ },
68
+ 'oas2-operation-formData-consume-check': {
69
+ description: 'Operations with "in: formData" parameter must include "application/x-www-form-urlencoded" or "multipart/form-data" in their "consumes" property.',
70
+ recommended: true,
71
+ formats: [openlint_formats_1.oas2],
72
+ given: '#OperationObject',
73
+ then: {
74
+ function: functions_1.oasOpFormDataConsumeCheck,
75
+ },
76
+ },
77
+ 'operation-operationId-unique': {
78
+ description: 'Every operation must have unique "operationId".',
79
+ recommended: true,
80
+ severity: 0,
81
+ given: '$.paths',
82
+ then: {
83
+ function: functions_1.oasOpIdUnique,
84
+ },
85
+ },
86
+ 'operation-parameters': {
87
+ description: 'Operation parameters are unique and non-repeating.',
88
+ message: '{{error}}',
89
+ recommended: true,
90
+ given: '#OperationObject.parameters',
91
+ then: {
92
+ function: functions_1.oasOpParams,
93
+ },
94
+ },
95
+ 'operation-tag-defined': {
96
+ description: 'Operation tags must be defined in global tags.',
97
+ recommended: true,
98
+ given: '$',
99
+ then: {
100
+ function: functions_1.oasTagDefined,
101
+ },
102
+ },
103
+ 'path-params': {
104
+ description: 'Path parameters must be defined and valid.',
105
+ message: '{{error}}',
106
+ severity: 0,
107
+ recommended: true,
108
+ given: '$.paths',
109
+ then: {
110
+ function: functions_1.oasPathParam,
111
+ },
112
+ },
113
+ 'contact-properties': {
114
+ description: 'Contact object must have "name", "url" and "email".',
115
+ recommended: false,
116
+ given: '$.info.contact',
117
+ then: [
118
+ {
119
+ field: 'name',
120
+ function: openlint_functions_1.truthy,
121
+ },
122
+ {
123
+ field: 'url',
124
+ function: openlint_functions_1.truthy,
125
+ },
126
+ {
127
+ field: 'email',
128
+ function: openlint_functions_1.truthy,
129
+ },
130
+ ],
131
+ },
132
+ 'duplicated-entry-in-enum': {
133
+ description: 'Enum values must not have duplicate entry.',
134
+ severity: 'warn',
135
+ recommended: true,
136
+ message: '{{error}}',
137
+ given: ["$..[?(@property !== 'properties' && @ != null && @.enum && @.enum.constructor.name === 'Array')]"],
138
+ then: {
139
+ field: 'enum',
140
+ function: functions_1.oasSchema,
141
+ functionOptions: {
142
+ schema: {
143
+ type: 'array',
144
+ uniqueItems: true,
145
+ },
146
+ },
147
+ },
148
+ },
149
+ 'info-contact': {
150
+ description: 'Info object must have "contact" object.',
151
+ recommended: true,
152
+ given: '$',
153
+ then: {
154
+ field: 'info.contact',
155
+ function: openlint_functions_1.truthy,
156
+ },
157
+ },
158
+ 'info-description': {
159
+ description: 'Info "description" must be present and non-empty string.',
160
+ recommended: true,
161
+ given: '$',
162
+ then: {
163
+ field: 'info.description',
164
+ function: openlint_functions_1.truthy,
165
+ },
166
+ },
167
+ 'info-license': {
168
+ description: 'Info object must have "license" object.',
169
+ recommended: false,
170
+ given: '$',
171
+ then: {
172
+ field: 'info.license',
173
+ function: openlint_functions_1.truthy,
174
+ },
175
+ },
176
+ 'license-url': {
177
+ description: 'License object must include "url".',
178
+ recommended: false,
179
+ given: '$',
180
+ then: {
181
+ field: 'info.license.url',
182
+ function: openlint_functions_1.truthy,
183
+ },
184
+ },
185
+ 'no-eval-in-markdown': {
186
+ description: 'Markdown descriptions must not have "eval(".',
187
+ recommended: true,
188
+ given: '$..[description,title]',
189
+ then: {
190
+ function: openlint_functions_1.pattern,
191
+ functionOptions: {
192
+ notMatch: 'eval\\(',
193
+ },
194
+ },
195
+ },
196
+ 'no-script-tags-in-markdown': {
197
+ description: 'Markdown descriptions must not have "<script>" tags.',
198
+ recommended: true,
199
+ given: '$..[description,title]',
200
+ then: {
201
+ function: openlint_functions_1.pattern,
202
+ functionOptions: {
203
+ notMatch: '<script',
204
+ },
205
+ },
206
+ },
207
+ 'openapi-tags-alphabetical': {
208
+ description: 'OpenAPI object must have alphabetical "tags".',
209
+ recommended: false,
210
+ given: '$',
211
+ then: {
212
+ field: 'tags',
213
+ function: openlint_functions_1.alphabetical,
214
+ functionOptions: {
215
+ keyedBy: 'name',
216
+ },
217
+ },
218
+ },
219
+ 'openapi-tags-uniqueness': {
220
+ description: 'Each tag must have a unique name.',
221
+ message: '{{error}}',
222
+ severity: 'error',
223
+ recommended: true,
224
+ given: '$.tags',
225
+ then: {
226
+ function: functions_2.uniquenessTags,
227
+ },
228
+ },
229
+ 'openapi-tags': {
230
+ description: 'OpenAPI object must have non-empty "tags" array.',
231
+ recommended: false,
232
+ given: '$',
233
+ then: {
234
+ field: 'tags',
235
+ function: openlint_functions_1.schema,
236
+ functionOptions: {
237
+ dialect: 'draft7',
238
+ schema: {
239
+ type: 'array',
240
+ minItems: 1,
241
+ },
242
+ },
243
+ },
244
+ },
245
+ 'operation-description': {
246
+ description: 'Operation "description" must be present and non-empty string.',
247
+ recommended: true,
248
+ given: '#OperationObject',
249
+ then: {
250
+ field: 'description',
251
+ function: openlint_functions_1.truthy,
252
+ },
253
+ },
254
+ 'operation-operationId': {
255
+ description: 'Operation must have "operationId".',
256
+ recommended: true,
257
+ given: '#OperationObject',
258
+ then: {
259
+ field: 'operationId',
260
+ function: openlint_functions_1.truthy,
261
+ },
262
+ },
263
+ 'operation-operationId-valid-in-url': {
264
+ message: 'operationId must not contain characters that are invalid when used in URL.',
265
+ recommended: true,
266
+ given: '#OperationObject',
267
+ then: {
268
+ field: 'operationId',
269
+ function: openlint_functions_1.pattern,
270
+ functionOptions: {
271
+ match: "^[A-Za-z0-9-._~:/?#\\[\\]@!\\$&'()*+,;=]*$",
272
+ },
273
+ },
274
+ },
275
+ 'operation-singular-tag': {
276
+ description: 'Operation must not have more than a single tag.',
277
+ recommended: false,
278
+ given: '#OperationObject',
279
+ then: {
280
+ field: 'tags',
281
+ function: openlint_functions_1.length,
282
+ functionOptions: {
283
+ max: 1,
284
+ },
285
+ },
286
+ },
287
+ 'operation-tags': {
288
+ description: 'Operation must have non-empty "tags" array.',
289
+ recommended: true,
290
+ given: '#OperationObject',
291
+ then: {
292
+ field: 'tags',
293
+ function: openlint_functions_1.schema,
294
+ functionOptions: {
295
+ dialect: 'draft7',
296
+ schema: {
297
+ type: 'array',
298
+ minItems: 1,
299
+ },
300
+ },
301
+ },
302
+ },
303
+ 'path-declarations-must-exist': {
304
+ message: 'Path parameter declarations must not be empty, ex."/given/{}" is invalid.',
305
+ recommended: true,
306
+ given: '$.paths',
307
+ then: {
308
+ field: '@key',
309
+ function: openlint_functions_1.pattern,
310
+ functionOptions: {
311
+ notMatch: '{}',
312
+ },
313
+ },
314
+ },
315
+ 'path-keys-no-trailing-slash': {
316
+ message: 'Path must not end with slash.',
317
+ recommended: true,
318
+ given: '$.paths',
319
+ then: {
320
+ field: '@key',
321
+ function: openlint_functions_1.pattern,
322
+ functionOptions: {
323
+ notMatch: '.+\\/$',
324
+ },
325
+ },
326
+ },
327
+ 'path-not-include-query': {
328
+ description: 'Path must not include query string.',
329
+ recommended: true,
330
+ given: '$.paths',
331
+ then: {
332
+ field: '@key',
333
+ function: openlint_functions_1.pattern,
334
+ functionOptions: {
335
+ notMatch: '\\?',
336
+ },
337
+ },
338
+ },
339
+ 'tag-description': {
340
+ description: 'Tag object must have "description".',
341
+ recommended: false,
342
+ given: '$.tags[*]',
343
+ then: {
344
+ field: 'description',
345
+ function: openlint_functions_1.truthy,
346
+ },
347
+ },
348
+ 'no-$ref-siblings': {
349
+ formats: [openlint_formats_1.oas2, openlint_formats_1.oas3_0],
350
+ description: 'Property must not be placed among $ref',
351
+ message: '{{error}}',
352
+ severity: 0,
353
+ recommended: true,
354
+ resolved: false,
355
+ given: "$..[?(@property === '$ref')]",
356
+ then: {
357
+ function: functions_1.refSiblings,
358
+ },
359
+ },
360
+ 'array-items': {
361
+ message: 'Schemas with "type: array", require a sibling "items" field',
362
+ severity: 0,
363
+ recommended: true,
364
+ resolved: false,
365
+ given: '#ArrayProperties',
366
+ then: {
367
+ function: openlint_functions_1.truthy,
368
+ field: 'items',
369
+ },
370
+ },
371
+ 'typed-enum': {
372
+ description: 'Enum values must respect the specified type.',
373
+ message: '{{error}}',
374
+ recommended: true,
375
+ given: '$..[?(@ && @.enum && @.type)]',
376
+ then: {
377
+ function: functions_1.typedEnum,
378
+ },
379
+ },
380
+ 'oas2-api-host': {
381
+ description: 'OpenAPI "host" must be present and non-empty string.',
382
+ recommended: true,
383
+ formats: [openlint_formats_1.oas2],
384
+ given: '$',
385
+ then: {
386
+ field: 'host',
387
+ function: openlint_functions_1.truthy,
388
+ },
389
+ },
390
+ 'oas2-api-schemes': {
391
+ description: 'OpenAPI host "schemes" must be present and non-empty array.',
392
+ recommended: true,
393
+ formats: [openlint_formats_1.oas2],
394
+ given: '$',
395
+ then: {
396
+ field: 'schemes',
397
+ function: openlint_functions_1.schema,
398
+ functionOptions: {
399
+ dialect: 'draft7',
400
+ schema: {
401
+ items: {
402
+ type: 'string',
403
+ },
404
+ minItems: 1,
405
+ type: 'array',
406
+ },
407
+ },
408
+ },
409
+ },
410
+ 'oas2-discriminator': {
411
+ description: 'discriminator property must be defined and required',
412
+ recommended: true,
413
+ formats: [openlint_formats_1.oas2],
414
+ severity: 0,
415
+ message: '{{error}}',
416
+ given: '$.definitions[?(@.discriminator)]',
417
+ then: {
418
+ function: functions_1.oasDiscriminator,
419
+ },
420
+ },
421
+ 'oas2-host-not-example': {
422
+ description: 'Host URL must not point at example.com.',
423
+ recommended: false,
424
+ formats: [openlint_formats_1.oas2],
425
+ given: '$',
426
+ then: {
427
+ field: 'host',
428
+ function: openlint_functions_1.pattern,
429
+ functionOptions: {
430
+ notMatch: 'example\\.com',
431
+ },
432
+ },
433
+ },
434
+ 'oas2-host-trailing-slash': {
435
+ description: 'Server URL must not have trailing slash.',
436
+ recommended: true,
437
+ formats: [openlint_formats_1.oas2],
438
+ given: '$',
439
+ then: {
440
+ field: 'host',
441
+ function: openlint_functions_1.pattern,
442
+ functionOptions: {
443
+ notMatch: '/$',
444
+ },
445
+ },
446
+ },
447
+ 'oas2-parameter-description': {
448
+ description: 'Parameter objects must have "description".',
449
+ recommended: false,
450
+ formats: [openlint_formats_1.oas2],
451
+ given: '$..parameters[?(@ && @.in)]',
452
+ then: {
453
+ field: 'description',
454
+ function: openlint_functions_1.truthy,
455
+ },
456
+ },
457
+ 'oas2-operation-security-defined': {
458
+ description: 'Operation "security" values must match a scheme defined in the "securityDefinitions" object.',
459
+ message: '{{error}}',
460
+ recommended: true,
461
+ formats: [openlint_formats_1.oas2],
462
+ given: '#SecurityRequirementObject',
463
+ then: {
464
+ function: functions_1.oasSecurityDefined,
465
+ functionOptions: {
466
+ oasVersion: 2,
467
+ },
468
+ },
469
+ },
470
+ 'oas2-valid-schema-example': {
471
+ description: 'Examples must be valid against their defined schema.',
472
+ message: '{{error}}',
473
+ recommended: true,
474
+ formats: [openlint_formats_1.oas2],
475
+ severity: 0,
476
+ given: [
477
+ "$..definitions..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
478
+ "$..parameters..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
479
+ "$..responses..[?(@property !== 'properties' && @ && (@.example !== void 0 || @['x-example'] !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
480
+ ],
481
+ then: {
482
+ function: functions_1.oasExample,
483
+ functionOptions: {
484
+ schemaField: '$',
485
+ oasVersion: 2,
486
+ type: 'schema',
487
+ },
488
+ },
489
+ },
490
+ 'oas2-valid-media-example': {
491
+ description: 'Examples must be valid against their defined schema.',
492
+ message: '{{error}}',
493
+ recommended: true,
494
+ formats: [openlint_formats_1.oas2],
495
+ severity: 0,
496
+ given: '$..responses..[?(@ && @.schema && @.examples)]',
497
+ then: {
498
+ function: functions_1.oasExample,
499
+ functionOptions: {
500
+ schemaField: 'schema',
501
+ oasVersion: 2,
502
+ type: 'media',
503
+ },
504
+ },
505
+ },
506
+ 'oas2-anyOf': {
507
+ message: '"anyOf" keyword must not be used in OpenAPI v2 document.',
508
+ description: 'anyOf is not available in OpenAPI v2, it was added in OpenAPI v3',
509
+ recommended: true,
510
+ formats: [openlint_formats_1.oas2],
511
+ given: '$..anyOf',
512
+ then: {
513
+ function: openlint_functions_1.undefined,
514
+ },
515
+ },
516
+ 'oas2-oneOf': {
517
+ message: '"oneOf" keyword must not be used in OpenAPI v2 document.',
518
+ description: 'oneOf is not available in OpenAPI v2, it was added in OpenAPI v3',
519
+ recommended: true,
520
+ formats: [openlint_formats_1.oas2],
521
+ given: '$..oneOf',
522
+ then: {
523
+ function: openlint_functions_1.undefined,
524
+ },
525
+ },
526
+ 'oas2-schema': {
527
+ description: 'Validate structure of OpenAPI v2 specification.',
528
+ message: '{{error}}.',
529
+ recommended: true,
530
+ formats: [openlint_formats_1.oas2],
531
+ severity: 0,
532
+ resolved: false,
533
+ given: '$',
534
+ then: {
535
+ function: functions_1.oasDocumentSchema,
536
+ },
537
+ },
538
+ 'oas2-unused-definition': {
539
+ description: 'Potentially unused definition has been detected.',
540
+ recommended: true,
541
+ resolved: false,
542
+ formats: [openlint_formats_1.oas2],
543
+ given: '$.definitions',
544
+ then: {
545
+ function: openlint_functions_1.unreferencedReusableObject,
546
+ functionOptions: {
547
+ reusableObjectsLocation: '#/definitions',
548
+ },
549
+ },
550
+ },
551
+ 'oas3-api-servers': {
552
+ description: 'OpenAPI "servers" must be present and non-empty array.',
553
+ recommended: true,
554
+ formats: [openlint_formats_1.oas3],
555
+ given: '$',
556
+ then: {
557
+ field: 'servers',
558
+ function: openlint_functions_1.schema,
559
+ functionOptions: {
560
+ dialect: 'draft7',
561
+ schema: {
562
+ items: {
563
+ type: 'object',
564
+ },
565
+ minItems: 1,
566
+ type: 'array',
567
+ },
568
+ },
569
+ },
570
+ },
571
+ 'oas3-examples-value-or-externalValue': {
572
+ description: 'Examples must have either "value" or "externalValue" field.',
573
+ recommended: true,
574
+ formats: [openlint_formats_1.oas3],
575
+ given: [
576
+ '$.components.examples[*]',
577
+ '$.paths[*][*]..content[*].examples[*]',
578
+ '$.paths[*][*]..parameters[*].examples[*]',
579
+ '$.components.parameters[*].examples[*]',
580
+ '$.paths[*][*]..headers[*].examples[*]',
581
+ '$.components.headers[*].examples[*]',
582
+ ],
583
+ then: {
584
+ function: openlint_functions_1.xor,
585
+ functionOptions: {
586
+ properties: ['externalValue', 'value'],
587
+ },
588
+ },
589
+ },
590
+ 'oas3-operation-security-defined': {
591
+ description: 'Operation "security" values must match a scheme defined in the "components.securitySchemes" object.',
592
+ message: '{{error}}',
593
+ recommended: true,
594
+ formats: [openlint_formats_1.oas3],
595
+ given: '#SecurityRequirementObject',
596
+ then: {
597
+ function: functions_1.oasSecurityDefined,
598
+ functionOptions: {
599
+ oasVersion: 3,
600
+ },
601
+ },
602
+ },
603
+ 'oas3-parameter-description': {
604
+ description: 'Parameter objects must have "description".',
605
+ recommended: false,
606
+ formats: [openlint_formats_1.oas3],
607
+ given: [
608
+ '#PathItem.parameters[?(@ && @.in)]',
609
+ '#OperationObject.parameters[?(@ && @.in)]',
610
+ '$.components.parameters[?(@ && @.in)]',
611
+ ],
612
+ then: {
613
+ field: 'description',
614
+ function: openlint_functions_1.truthy,
615
+ },
616
+ },
617
+ 'oas3-server-not-example.com': {
618
+ description: 'Server URL must not point at example.com.',
619
+ recommended: false,
620
+ formats: [openlint_formats_1.oas3],
621
+ given: '$.servers[*].url',
622
+ then: {
623
+ function: openlint_functions_1.pattern,
624
+ functionOptions: {
625
+ notMatch: 'example\\.com',
626
+ },
627
+ },
628
+ },
629
+ 'oas3-server-trailing-slash': {
630
+ description: 'Server URL must not have trailing slash.',
631
+ recommended: true,
632
+ formats: [openlint_formats_1.oas3],
633
+ given: '$.servers[*].url',
634
+ then: {
635
+ function: openlint_functions_1.pattern,
636
+ functionOptions: {
637
+ notMatch: './$',
638
+ },
639
+ },
640
+ },
641
+ 'oas3-valid-media-example': {
642
+ description: 'Examples must be valid against their defined schema.',
643
+ message: '{{error}}',
644
+ recommended: true,
645
+ severity: 0,
646
+ formats: [openlint_formats_1.oas3],
647
+ given: [
648
+ '$..content..[?(@ && @.schema && (@.example !== void 0 || @.examples))]',
649
+ '$..headers..[?(@ && @.schema && (@.example !== void 0 || @.examples))]',
650
+ '$..parameters..[?(@ && @.schema && (@.example !== void 0 || @.examples))]',
651
+ ],
652
+ then: {
653
+ function: functions_1.oasExample,
654
+ functionOptions: {
655
+ schemaField: 'schema',
656
+ oasVersion: 3,
657
+ type: 'media',
658
+ },
659
+ },
660
+ },
661
+ 'oas3-valid-schema-example': {
662
+ description: 'Examples must be valid against their defined schema.',
663
+ message: '{{error}}',
664
+ severity: 0,
665
+ formats: [openlint_formats_1.oas3],
666
+ recommended: true,
667
+ given: [
668
+ "$.components.schemas..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
669
+ "$..content..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
670
+ "$..headers..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
671
+ "$..parameters..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]",
672
+ ],
673
+ then: {
674
+ function: functions_1.oasExample,
675
+ functionOptions: {
676
+ schemaField: '$',
677
+ oasVersion: 3,
678
+ type: 'schema',
679
+ },
680
+ },
681
+ },
682
+ 'oas3-schema': {
683
+ description: 'Validate structure of OpenAPI v3 specification.',
684
+ message: '{{error}}.',
685
+ severity: 0,
686
+ formats: [openlint_formats_1.oas3],
687
+ recommended: true,
688
+ resolved: false,
689
+ given: '$',
690
+ then: {
691
+ function: functions_1.oasDocumentSchema,
692
+ },
693
+ },
694
+ 'oas3-unused-component': {
695
+ message: 'Potentially unused component has been detected.',
696
+ recommended: true,
697
+ formats: [openlint_formats_1.oas3],
698
+ resolved: false,
699
+ given: '$',
700
+ then: {
701
+ function: functions_1.oasUnusedComponent,
702
+ },
703
+ },
704
+ 'oas3-server-variables': {
705
+ description: 'Server variables must be defined and valid and there must be no unused variables.',
706
+ message: '{{error}}',
707
+ severity: 0,
708
+ recommended: true,
709
+ given: ['$.servers[*]', '#PathItem.servers[*]', '#OperationObject.servers[*]', '#LinkObject.server'],
710
+ then: {
711
+ function: serverVariables_1.default,
712
+ functionOptions: {
713
+ checkSubstitutions: true,
714
+ requireDefault: true,
715
+ },
716
+ },
717
+ },
718
+ 'oas3-callbacks-in-callbacks': {
719
+ message: 'Callbacks should not be defined within a callback',
720
+ formats: [openlint_formats_1.oas3],
721
+ recommended: true,
722
+ given: ['#OperationObject.callbacks[*][*][*].callbacks'],
723
+ then: {
724
+ function: openlint_functions_1.undefined,
725
+ },
726
+ },
727
+ 'oas3_1-servers-in-webhook': {
728
+ message: 'Servers should not be defined in a webhook.',
729
+ formats: [openlint_formats_1.oas3_1, openlint_formats_1.oas3_2],
730
+ recommended: true,
731
+ given: ['$.webhooks.servers', '$.webhooks[*][*].servers'],
732
+ then: {
733
+ function: openlint_functions_1.undefined,
734
+ },
735
+ },
736
+ 'oas3_1-callbacks-in-webhook': {
737
+ message: 'Callbacks should not be defined in a webhook.',
738
+ formats: [openlint_formats_1.oas3_1, openlint_formats_1.oas3_2],
739
+ recommended: true,
740
+ given: ['$.webhooks[*][*].callbacks'],
741
+ then: {
742
+ function: openlint_functions_1.undefined,
743
+ },
744
+ },
745
+ 'oas3_2-no-deprecated-xml-attribute': {
746
+ message: '"xml.attribute" is deprecated in OAS 3.2; use "xml.nodeType: attribute" instead.',
747
+ formats: [openlint_formats_1.oas3_2],
748
+ recommended: true,
749
+ given: ['$..[?(@ && @.xml)].xml'],
750
+ then: {
751
+ function: openlint_functions_1.schema,
752
+ functionOptions: {
753
+ schema: {
754
+ not: {
755
+ properties: { attribute: { const: true } },
756
+ required: ['attribute'],
757
+ },
758
+ },
759
+ },
760
+ },
761
+ },
762
+ },
763
+ };
764
+ exports.default = ruleset;
765
+ //# sourceMappingURL=index.js.map