@redocly/openapi-core 1.3.0 → 1.4.1

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 (202) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
  3. package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
  4. package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
  5. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
  6. package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
  7. package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
  8. package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
  9. package/lib/benchmark/utils.js +3 -3
  10. package/lib/bundle.d.ts +4 -4
  11. package/lib/bundle.js +25 -25
  12. package/lib/config/all.d.ts +2 -2
  13. package/lib/config/all.js +44 -8
  14. package/lib/config/builtIn.js +2 -0
  15. package/lib/config/config-resolvers.js +25 -25
  16. package/lib/config/config.js +9 -9
  17. package/lib/config/index.js +5 -1
  18. package/lib/config/load.d.ts +1 -1
  19. package/lib/config/load.js +6 -6
  20. package/lib/config/minimal.d.ts +2 -2
  21. package/lib/config/minimal.js +34 -3
  22. package/lib/config/recommended-strict.d.ts +3 -0
  23. package/lib/config/recommended-strict.js +92 -0
  24. package/lib/config/recommended.d.ts +2 -2
  25. package/lib/config/recommended.js +34 -3
  26. package/lib/config/rules.d.ts +1 -1
  27. package/lib/config/types.d.ts +47 -46
  28. package/lib/config/types.js +2 -2
  29. package/lib/config/utils.js +26 -14
  30. package/lib/decorators/common/filters/filter-helper.js +4 -4
  31. package/lib/decorators/common/filters/filter-in.js +2 -2
  32. package/lib/decorators/common/filters/filter-out.js +2 -2
  33. package/lib/decorators/common/info-description-override.js +1 -1
  34. package/lib/decorators/common/media-type-examples-override.js +3 -3
  35. package/lib/decorators/common/operation-description-override.js +1 -1
  36. package/lib/decorators/common/registry-dependencies.js +1 -1
  37. package/lib/decorators/common/remove-x-internal.js +4 -4
  38. package/lib/decorators/common/tag-description-override.js +1 -1
  39. package/lib/decorators/oas2/remove-unused-components.d.ts +2 -0
  40. package/lib/{rules → decorators}/oas2/remove-unused-components.js +1 -1
  41. package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
  42. package/lib/{rules → decorators}/oas3/remove-unused-components.js +2 -2
  43. package/lib/env.js +1 -1
  44. package/lib/format/codeframes.d.ts +6 -6
  45. package/lib/format/format.d.ts +2 -2
  46. package/lib/format/format.js +12 -12
  47. package/lib/js-yaml/index.d.ts +2 -2
  48. package/lib/js-yaml/index.js +2 -2
  49. package/lib/lint.js +18 -18
  50. package/lib/oas-types.d.ts +12 -10
  51. package/lib/oas-types.js +2 -2
  52. package/lib/redocly/index.js +10 -10
  53. package/lib/redocly/registry-api.js +2 -2
  54. package/lib/resolve.d.ts +4 -4
  55. package/lib/resolve.js +18 -18
  56. package/lib/rules/ajv.js +1 -1
  57. package/lib/rules/async2/index.d.ts +2 -11
  58. package/lib/rules/common/assertions/asserts.d.ts +3 -3
  59. package/lib/rules/common/assertions/asserts.js +21 -21
  60. package/lib/rules/common/assertions/index.d.ts +4 -4
  61. package/lib/rules/common/assertions/index.js +3 -3
  62. package/lib/rules/common/assertions/utils.d.ts +4 -4
  63. package/lib/rules/common/assertions/utils.js +3 -3
  64. package/lib/rules/common/info-contact.js +1 -1
  65. package/lib/rules/common/info-license-url.js +1 -1
  66. package/lib/rules/common/info-license.js +1 -1
  67. package/lib/rules/common/no-enum-type-mismatch.js +3 -3
  68. package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
  69. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  70. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  71. package/lib/rules/common/operation-2xx-response.js +2 -2
  72. package/lib/rules/common/operation-4xx-response.js +2 -2
  73. package/lib/rules/common/operation-description.js +1 -1
  74. package/lib/rules/common/operation-operationId.js +1 -1
  75. package/lib/rules/common/operation-summary.js +1 -1
  76. package/lib/rules/common/path-segment-plural.js +1 -1
  77. package/lib/rules/common/response-contains-header.js +2 -2
  78. package/lib/rules/common/spec-strict-refs.js +1 -1
  79. package/lib/rules/common/spec.js +11 -11
  80. package/lib/rules/common/tag-description.js +1 -1
  81. package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
  82. package/lib/rules/oas2/index.d.ts +2 -46
  83. package/lib/rules/oas2/request-mime-type.js +2 -2
  84. package/lib/rules/oas2/response-contains-property.js +2 -2
  85. package/lib/rules/oas2/response-mime-type.js +2 -2
  86. package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
  87. package/lib/rules/oas3/index.d.ts +1 -1
  88. package/lib/rules/oas3/index.js +1 -1
  89. package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
  90. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
  91. package/lib/rules/oas3/request-mime-type.js +3 -3
  92. package/lib/rules/oas3/response-contains-property.js +2 -2
  93. package/lib/rules/oas3/response-mime-type.js +3 -3
  94. package/lib/rules/utils.js +3 -3
  95. package/lib/types/asyncapi.js +21 -21
  96. package/lib/types/index.d.ts +8 -8
  97. package/lib/types/oas2.js +14 -14
  98. package/lib/types/oas3.js +27 -27
  99. package/lib/types/oas3_1.js +18 -6
  100. package/lib/types/redocly-yaml.d.ts +11 -0
  101. package/lib/types/redocly-yaml.js +71 -53
  102. package/lib/types/theme-config.js +1 -1
  103. package/lib/typings/common.d.ts +2 -2
  104. package/lib/typings/openapi.d.ts +6 -6
  105. package/lib/typings/swagger.d.ts +3 -3
  106. package/lib/utils.d.ts +5 -5
  107. package/lib/utils.js +3 -3
  108. package/lib/visitors.d.ts +38 -40
  109. package/lib/walk.d.ts +14 -15
  110. package/lib/walk.js +11 -11
  111. package/package.json +2 -2
  112. package/src/__tests__/lint.test.ts +40 -40
  113. package/src/__tests__/normalizeVisitors.test.ts +23 -5
  114. package/src/__tests__/ref-utils.test.ts +7 -7
  115. package/src/__tests__/resolve-http.test.ts +10 -10
  116. package/src/__tests__/resolve.test.ts +39 -39
  117. package/src/__tests__/walk.test.ts +48 -48
  118. package/src/bundle.ts +4 -4
  119. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
  120. package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
  121. package/src/config/__tests__/config-resolvers.test.ts +30 -1
  122. package/src/config/__tests__/config.test.ts +88 -88
  123. package/src/config/__tests__/load.test.ts +12 -8
  124. package/src/config/__tests__/utils.test.ts +18 -18
  125. package/src/config/all.ts +46 -9
  126. package/src/config/builtIn.ts +2 -0
  127. package/src/config/minimal.ts +36 -4
  128. package/src/config/recommended-strict.ts +93 -0
  129. package/src/config/recommended.ts +36 -4
  130. package/src/config/types.ts +22 -8
  131. package/src/config/utils.ts +15 -0
  132. package/src/decorators/common/media-type-examples-override.ts +2 -2
  133. package/src/{rules → decorators}/oas2/remove-unused-components.ts +3 -3
  134. package/src/{rules → decorators}/oas3/remove-unused-components.ts +3 -3
  135. package/src/env.ts +1 -1
  136. package/src/lint.ts +3 -3
  137. package/src/oas-types.ts +26 -3
  138. package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
  139. package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
  140. package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
  141. package/src/rules/async2/index.ts +2 -1
  142. package/src/rules/common/__tests__/info-license.test.ts +6 -6
  143. package/src/rules/common/__tests__/license-url.test.ts +6 -6
  144. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
  145. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
  146. package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
  147. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
  148. package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
  149. package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
  150. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
  151. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
  152. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
  153. package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
  154. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
  155. package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
  156. package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
  157. package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
  158. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
  159. package/src/rules/common/__tests__/security-defined.test.ts +21 -21
  160. package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
  161. package/src/rules/common/__tests__/spec.test.ts +102 -102
  162. package/src/rules/common/__tests__/tag-description.test.ts +6 -6
  163. package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
  164. package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
  165. package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
  166. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  167. package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
  168. package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
  169. package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
  170. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  171. package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
  172. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
  173. package/src/rules/oas2/index.ts +3 -1
  174. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  175. package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
  176. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
  177. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
  178. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
  179. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
  180. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
  181. package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
  182. package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
  183. package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
  184. package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
  185. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  186. package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
  187. package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
  188. package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
  189. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
  190. package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
  191. package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
  192. package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
  193. package/src/rules/oas3/index.ts +3 -3
  194. package/src/types/oas3_1.ts +12 -0
  195. package/src/types/redocly-yaml.ts +75 -40
  196. package/src/visitors.ts +10 -21
  197. package/src/walk.ts +23 -10
  198. package/tsconfig.tsbuildinfo +1 -1
  199. package/lib/rules/oas2/remove-unused-components.d.ts +0 -2
  200. package/lib/rules/oas3/remove-unused-components.d.ts +0 -2
  201. /package/src/{rules → decorators}/oas2/__tests__/remove-unused-components.test.ts +0 -0
  202. /package/src/{rules → decorators}/oas3/__tests__/remove-unused-components.test.ts +0 -0
@@ -36,45 +36,45 @@ exports.runOnValuesSet = new Set([
36
36
  ]);
37
37
  exports.asserts = {
38
38
  pattern: (value, condition, { baseLocation, rawValue }) => {
39
- if (typeof value === 'undefined' || utils_1.isPlainObject(value))
39
+ if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value))
40
40
  return []; // property doesn't exist or is an object, no need to lint it with this assert
41
41
  const values = Array.isArray(value) ? value : [value];
42
- const regex = utils_2.regexFromString(condition);
42
+ const regex = (0, utils_2.regexFromString)(condition);
43
43
  return values
44
44
  .map((_val) => !(regex === null || regex === void 0 ? void 0 : regex.test(_val)) && {
45
45
  message: `"${_val}" should match a regex ${condition}`,
46
- location: utils_1.isString(value)
46
+ location: (0, utils_1.isString)(value)
47
47
  ? baseLocation
48
- : utils_1.isPlainObject(rawValue)
48
+ : (0, utils_1.isPlainObject)(rawValue)
49
49
  ? baseLocation.child(_val).key()
50
50
  : baseLocation.key(),
51
51
  })
52
52
  .filter(utils_1.isTruthy);
53
53
  },
54
54
  notPattern: (value, condition, { baseLocation, rawValue }) => {
55
- if (typeof value === 'undefined' || utils_1.isPlainObject(value))
55
+ if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value))
56
56
  return []; // property doesn't exist or is an object, no need to lint it with this assert
57
57
  const values = Array.isArray(value) ? value : [value];
58
- const regex = utils_2.regexFromString(condition);
58
+ const regex = (0, utils_2.regexFromString)(condition);
59
59
  return values
60
60
  .map((_val) => (regex === null || regex === void 0 ? void 0 : regex.test(_val)) && {
61
61
  message: `"${_val}" should not match a regex ${condition}`,
62
- location: utils_1.isString(value)
62
+ location: (0, utils_1.isString)(value)
63
63
  ? baseLocation
64
- : utils_1.isPlainObject(rawValue)
64
+ : (0, utils_1.isPlainObject)(rawValue)
65
65
  ? baseLocation.child(_val).key()
66
66
  : baseLocation.key(),
67
67
  })
68
68
  .filter(utils_1.isTruthy);
69
69
  },
70
70
  enum: (value, condition, { baseLocation }) => {
71
- if (typeof value === 'undefined' || utils_1.isPlainObject(value))
71
+ if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value))
72
72
  return []; // property doesn't exist or is an object, no need to lint it with this assert
73
73
  const values = Array.isArray(value) ? value : [value];
74
74
  return values
75
75
  .map((_val) => !condition.includes(_val) && {
76
76
  message: `"${_val}" should be one of the predefined values`,
77
- location: utils_1.isString(value) ? baseLocation : baseLocation.child(_val).key(),
77
+ location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(),
78
78
  })
79
79
  .filter(utils_1.isTruthy);
80
80
  },
@@ -99,13 +99,13 @@ exports.asserts = {
99
99
  .filter(utils_1.isTruthy);
100
100
  },
101
101
  disallowed: (value, condition, { baseLocation }) => {
102
- if (typeof value === 'undefined' || utils_1.isPlainObject(value))
102
+ if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value))
103
103
  return []; // property doesn't exist or is an object, no need to lint it with this assert
104
104
  const values = Array.isArray(value) ? value : [value];
105
105
  return values
106
106
  .map((_val) => condition.includes(_val) && {
107
107
  message: `"${_val}" is disallowed`,
108
- location: utils_1.isString(value) ? baseLocation : baseLocation.child(_val).key(),
108
+ location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(),
109
109
  })
110
110
  .filter(utils_1.isTruthy);
111
111
  },
@@ -116,7 +116,7 @@ exports.asserts = {
116
116
  return value
117
117
  .map((_val) => condition !== _val && {
118
118
  message: `"${_val}" should be equal ${condition} `,
119
- location: utils_1.isString(value) ? baseLocation : baseLocation.child(_val).key(),
119
+ location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(),
120
120
  })
121
121
  .filter(utils_1.isTruthy);
122
122
  }
@@ -176,7 +176,7 @@ exports.asserts = {
176
176
  ];
177
177
  },
178
178
  casing: (value, condition, { baseLocation }) => {
179
- if (typeof value === 'undefined' || utils_1.isPlainObject(value))
179
+ if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value))
180
180
  return []; // property doesn't exist or is an object, no need to lint it with this assert
181
181
  const values = Array.isArray(value) ? value : [value];
182
182
  const casingRegexes = {
@@ -191,7 +191,7 @@ exports.asserts = {
191
191
  return values
192
192
  .map((_val) => !_val.match(casingRegexes[condition]) && {
193
193
  message: `"${_val}" should use ${condition}`,
194
- location: utils_1.isString(value) ? baseLocation : baseLocation.child(_val).key(),
194
+ location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(),
195
195
  })
196
196
  .filter(utils_1.isTruthy);
197
197
  },
@@ -206,7 +206,7 @@ exports.asserts = {
206
206
  },
207
207
  ];
208
208
  }
209
- if (typeof value === 'undefined' || utils_2.isOrdered(value, condition))
209
+ if (typeof value === 'undefined' || (0, utils_2.isOrdered)(value, condition))
210
210
  return [];
211
211
  return [
212
212
  {
@@ -216,7 +216,7 @@ exports.asserts = {
216
216
  ];
217
217
  },
218
218
  mutuallyExclusive: (value, condition, { baseLocation }) => {
219
- if (utils_2.getIntersectionLength(value, condition) < 2)
219
+ if ((0, utils_2.getIntersectionLength)(value, condition) < 2)
220
220
  return [];
221
221
  return [
222
222
  {
@@ -226,8 +226,8 @@ exports.asserts = {
226
226
  ];
227
227
  },
228
228
  mutuallyRequired: (value, condition, { baseLocation }) => {
229
- const isValid = utils_2.getIntersectionLength(value, condition) > 0
230
- ? utils_2.getIntersectionLength(value, condition) === condition.length
229
+ const isValid = (0, utils_2.getIntersectionLength)(value, condition) > 0
230
+ ? (0, utils_2.getIntersectionLength)(value, condition) === condition.length
231
231
  : true;
232
232
  return isValid
233
233
  ? []
@@ -239,7 +239,7 @@ exports.asserts = {
239
239
  ];
240
240
  },
241
241
  requireAny: (value, condition, { baseLocation }) => {
242
- return utils_2.getIntersectionLength(value, condition) >= 1
242
+ return (0, utils_2.getIntersectionLength)(value, condition) >= 1
243
243
  ? []
244
244
  : [
245
245
  {
@@ -263,7 +263,7 @@ exports.asserts = {
263
263
  },
264
264
  ];
265
265
  }
266
- const regex = utils_2.regexFromString(condition);
266
+ const regex = (0, utils_2.regexFromString)(condition);
267
267
  const isValid = hasRef && (regex === null || regex === void 0 ? void 0 : regex.test(rawValue['$ref']));
268
268
  return isValid
269
269
  ? []
@@ -1,12 +1,12 @@
1
1
  import { asserts, AssertionFn } from './asserts';
2
2
  import { Oas2Visitor, Oas3Visitor } from '../../../visitors';
3
3
  import { RuleSeverity } from '../../../config';
4
- export declare type AssertionLocators = {
4
+ export type AssertionLocators = {
5
5
  filterInParentKeys?: (string | number)[];
6
6
  filterOutParentKeys?: (string | number)[];
7
7
  matchParentKeys?: string;
8
8
  };
9
- export declare type AssertionDefinition = {
9
+ export type AssertionDefinition = {
10
10
  subject: {
11
11
  type: string;
12
12
  property?: string | string[];
@@ -15,13 +15,13 @@ export declare type AssertionDefinition = {
15
15
  [name in keyof typeof asserts]?: AssertionFn;
16
16
  };
17
17
  };
18
- export declare type RawAssertion = AssertionDefinition & {
18
+ export type RawAssertion = AssertionDefinition & {
19
19
  where?: AssertionDefinition[];
20
20
  message?: string;
21
21
  suggest?: string[];
22
22
  severity?: RuleSeverity;
23
23
  };
24
- export declare type Assertion = RawAssertion & {
24
+ export type Assertion = RawAssertion & {
25
25
  assertionId: string;
26
26
  };
27
27
  export declare const Assertions: (opts: Record<string, Assertion>) => (Oas3Visitor | Oas2Visitor)[];
@@ -12,11 +12,11 @@ const Assertions = (opts) => {
12
12
  // before - filter only object 'opts' values
13
13
  const assertions = Object.values(opts).filter((opt) => typeof opt === 'object' && opt !== null);
14
14
  for (const [_, assertion] of assertions.entries()) {
15
- if (!utils_2.isString(assertion.subject.type)) {
15
+ if (!(0, utils_2.isString)(assertion.subject.type)) {
16
16
  throw new Error(`${assertion.assertionId}: 'type' (String) is required`);
17
17
  }
18
- const subjectVisitor = utils_1.buildSubjectVisitor(assertion.assertionId, assertion);
19
- const visitorObject = utils_1.buildVisitorObject(assertion, subjectVisitor);
18
+ const subjectVisitor = (0, utils_1.buildSubjectVisitor)(assertion.assertionId, assertion);
19
+ const visitorObject = (0, utils_1.buildVisitorObject)(assertion, subjectVisitor);
20
20
  visitors.push(visitorObject);
21
21
  }
22
22
  return visitors;
@@ -2,18 +2,18 @@ import { Asserts } from './asserts';
2
2
  import type { AssertionContext, AssertResult } from '../../../config';
3
3
  import type { Assertion, AssertionDefinition } from '.';
4
4
  import type { Oas2Visitor, Oas3Visitor, VisitFunction } from '../../../visitors';
5
- export declare type OrderDirection = 'asc' | 'desc';
6
- export declare type OrderOptions = {
5
+ export type OrderDirection = 'asc' | 'desc';
6
+ export type OrderOptions = {
7
7
  direction: OrderDirection;
8
8
  property: string;
9
9
  };
10
- export declare type AssertToApply = {
10
+ export type AssertToApply = {
11
11
  name: keyof Asserts;
12
12
  conditions: any;
13
13
  runsOnKeys: boolean;
14
14
  runsOnValues: boolean;
15
15
  };
16
- declare type RunAssertionParams = {
16
+ type RunAssertionParams = {
17
17
  ctx: AssertionContext;
18
18
  assert: AssertToApply;
19
19
  assertionProperty?: string;
@@ -19,7 +19,7 @@ function getPredicatesFromLocators(locators) {
19
19
  return [matchKeysPredicate, filterInPredicate, filterOutPredicate].filter(utils_1.isTruthy);
20
20
  }
21
21
  function getAssertsToApply(assertion) {
22
- const assertsToApply = utils_1.keysOf(asserts_1.asserts)
22
+ const assertsToApply = (0, utils_1.keysOf)(asserts_1.asserts)
23
23
  .filter((assertName) => assertion.assertions[assertName] !== undefined)
24
24
  .map((assertName) => {
25
25
  return {
@@ -82,7 +82,7 @@ function buildVisitorObject(assertion, subjectVisitor) {
82
82
  const context = assertion.where;
83
83
  for (let index = 0; index < context.length; index++) {
84
84
  const assertionDefinitionNode = context[index];
85
- if (!utils_1.isString((_a = assertionDefinitionNode.subject) === null || _a === void 0 ? void 0 : _a.type)) {
85
+ if (!(0, utils_1.isString)((_a = assertionDefinitionNode.subject) === null || _a === void 0 ? void 0 : _a.type)) {
86
86
  throw new Error(`${assertion.assertionId} -> where -> [${index}]: 'type' (String) is required`);
87
87
  }
88
88
  const locatorPredicates = getPredicatesFromLocators(assertionDefinitionNode.subject);
@@ -191,7 +191,7 @@ function runAssertion({ assert, ctx, assertionProperty, }) {
191
191
  var _a;
192
192
  const currentLocation = assert.name === 'ref' ? ctx.rawLocation : ctx.location;
193
193
  if (assertionProperty) {
194
- const values = ref_utils_1.isRef(ctx.node[assertionProperty])
194
+ const values = (0, ref_utils_1.isRef)(ctx.node[assertionProperty])
195
195
  ? (_a = ctx.resolve(ctx.node[assertionProperty])) === null || _a === void 0 ? void 0 : _a.node
196
196
  : ctx.node[assertionProperty];
197
197
  const rawValues = ctx.rawNode[assertionProperty];
@@ -7,7 +7,7 @@ const InfoContact = () => {
7
7
  Info(info, { report, location }) {
8
8
  if (!info.contact) {
9
9
  report({
10
- message: utils_1.missingRequiredField('Info', 'contact'),
10
+ message: (0, utils_1.missingRequiredField)('Info', 'contact'),
11
11
  location: location.child('contact').key(),
12
12
  });
13
13
  }
@@ -5,7 +5,7 @@ const utils_1 = require("../utils");
5
5
  const InfoLicenseUrl = () => {
6
6
  return {
7
7
  License(license, ctx) {
8
- utils_1.validateDefinedAndNonEmpty('url', license, ctx);
8
+ (0, utils_1.validateDefinedAndNonEmpty)('url', license, ctx);
9
9
  },
10
10
  };
11
11
  };
@@ -7,7 +7,7 @@ const InfoLicense = () => {
7
7
  Info(info, { report }) {
8
8
  if (!info.license) {
9
9
  report({
10
- message: utils_1.missingRequiredField('Info', 'license'),
10
+ message: (0, utils_1.missingRequiredField)('Info', 'license'),
11
11
  location: { reportOnKey: true },
12
12
  });
13
13
  }
@@ -8,10 +8,10 @@ const NoEnumTypeMismatch = () => {
8
8
  if (schema.enum && !Array.isArray(schema.enum))
9
9
  return;
10
10
  if (schema.enum && schema.type && !Array.isArray(schema.type)) {
11
- const typeMismatchedValues = schema.enum.filter((item) => !utils_1.matchesJsonSchemaType(item, schema.type, schema.nullable));
11
+ const typeMismatchedValues = schema.enum.filter((item) => !(0, utils_1.matchesJsonSchemaType)(item, schema.type, schema.nullable));
12
12
  for (const mismatchedValue of typeMismatchedValues) {
13
13
  report({
14
- message: `All values of \`enum\` field must be of the same type as the \`type\` field: expected "${schema.type}" but received "${utils_1.oasTypeOf(mismatchedValue)}".`,
14
+ message: `All values of \`enum\` field must be of the same type as the \`type\` field: expected "${schema.type}" but received "${(0, utils_1.oasTypeOf)(mismatchedValue)}".`,
15
15
  location: location.child(['enum', schema.enum.indexOf(mismatchedValue)]),
16
16
  });
17
17
  }
@@ -21,7 +21,7 @@ const NoEnumTypeMismatch = () => {
21
21
  for (const enumValue of schema.enum) {
22
22
  mismatchedResults[enumValue] = [];
23
23
  for (const type of schema.type) {
24
- const valid = utils_1.matchesJsonSchemaType(enumValue, type, schema.nullable);
24
+ const valid = (0, utils_1.matchesJsonSchemaType)(enumValue, type, schema.nullable);
25
25
  if (!valid)
26
26
  mismatchedResults[enumValue].push(type);
27
27
  }
@@ -11,11 +11,11 @@ const NoHttpVerbsInPaths = ({ splitIntoWords }) => {
11
11
  return;
12
12
  const pathSegments = pathKey.split('/');
13
13
  for (const pathSegment of pathSegments) {
14
- if (!pathSegment || utils_1.isPathParameter(pathSegment))
14
+ if (!pathSegment || (0, utils_1.isPathParameter)(pathSegment))
15
15
  continue;
16
16
  const isHttpMethodIncluded = (method) => {
17
17
  return splitIntoWords
18
- ? utils_1.splitCamelCaseIntoWords(pathSegment).has(method)
18
+ ? (0, utils_1.splitCamelCaseIntoWords)(pathSegment).has(method)
19
19
  : pathSegment.toLocaleLowerCase().includes(method);
20
20
  };
21
21
  for (const method of httpMethods) {
@@ -4,17 +4,17 @@ exports.NoInvalidParameterExamples = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const NoInvalidParameterExamples = (opts) => {
6
6
  var _a;
7
- const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
7
+ const allowAdditionalProperties = (_a = (0, utils_1.getAdditionalPropertiesOption)(opts)) !== null && _a !== void 0 ? _a : false;
8
8
  return {
9
9
  Parameter: {
10
10
  leave(parameter, ctx) {
11
11
  if (parameter.example) {
12
- utils_1.validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties);
12
+ (0, utils_1.validateExample)(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties);
13
13
  }
14
14
  if (parameter.examples) {
15
15
  for (const [key, example] of Object.entries(parameter.examples)) {
16
16
  if ('value' in example) {
17
- utils_1.validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true);
17
+ (0, utils_1.validateExample)(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true);
18
18
  }
19
19
  }
20
20
  }
@@ -4,17 +4,17 @@ exports.NoInvalidSchemaExamples = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const NoInvalidSchemaExamples = (opts) => {
6
6
  var _a;
7
- const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
7
+ const allowAdditionalProperties = (_a = (0, utils_1.getAdditionalPropertiesOption)(opts)) !== null && _a !== void 0 ? _a : false;
8
8
  return {
9
9
  Schema: {
10
10
  leave(schema, ctx) {
11
11
  if (schema.examples) {
12
12
  for (const example of schema.examples) {
13
- utils_1.validateExample(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx, allowAdditionalProperties);
13
+ (0, utils_1.validateExample)(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx, allowAdditionalProperties);
14
14
  }
15
15
  }
16
16
  if (schema.example) {
17
- utils_1.validateExample(schema.example, schema, ctx.location.child('example'), ctx, true);
17
+ (0, utils_1.validateExample)(schema.example, schema, ctx.location.child('example'), ctx, true);
18
18
  }
19
19
  },
20
20
  },
@@ -7,7 +7,7 @@ const Operation2xxResponse = ({ validateWebhooks }) => {
7
7
  Paths: {
8
8
  Responses(responses, { report }) {
9
9
  const codes = Object.keys(responses || {});
10
- utils_1.validateResponseCodes(codes, '2XX', { report });
10
+ (0, utils_1.validateResponseCodes)(codes, '2XX', { report });
11
11
  },
12
12
  },
13
13
  WebhooksMap: {
@@ -15,7 +15,7 @@ const Operation2xxResponse = ({ validateWebhooks }) => {
15
15
  if (!validateWebhooks)
16
16
  return;
17
17
  const codes = Object.keys(responses || {});
18
- utils_1.validateResponseCodes(codes, '2XX', { report });
18
+ (0, utils_1.validateResponseCodes)(codes, '2XX', { report });
19
19
  },
20
20
  },
21
21
  };
@@ -7,7 +7,7 @@ const Operation4xxResponse = ({ validateWebhooks }) => {
7
7
  Paths: {
8
8
  Responses(responses, { report }) {
9
9
  const codes = Object.keys(responses || {});
10
- utils_1.validateResponseCodes(codes, '4XX', { report });
10
+ (0, utils_1.validateResponseCodes)(codes, '4XX', { report });
11
11
  },
12
12
  },
13
13
  WebhooksMap: {
@@ -15,7 +15,7 @@ const Operation4xxResponse = ({ validateWebhooks }) => {
15
15
  if (!validateWebhooks)
16
16
  return;
17
17
  const codes = Object.keys(responses || {});
18
- utils_1.validateResponseCodes(codes, '4XX', { report });
18
+ (0, utils_1.validateResponseCodes)(codes, '4XX', { report });
19
19
  },
20
20
  },
21
21
  };
@@ -5,7 +5,7 @@ const utils_1 = require("../utils");
5
5
  const OperationDescription = () => {
6
6
  return {
7
7
  Operation(operation, ctx) {
8
- utils_1.validateDefinedAndNonEmpty('description', operation, ctx);
8
+ (0, utils_1.validateDefinedAndNonEmpty)('description', operation, ctx);
9
9
  },
10
10
  };
11
11
  };
@@ -7,7 +7,7 @@ const OperationOperationId = () => {
7
7
  Root: {
8
8
  PathItem: {
9
9
  Operation(operation, ctx) {
10
- utils_1.validateDefinedAndNonEmpty('operationId', operation, ctx);
10
+ (0, utils_1.validateDefinedAndNonEmpty)('operationId', operation, ctx);
11
11
  },
12
12
  },
13
13
  },
@@ -5,7 +5,7 @@ const utils_1 = require("../utils");
5
5
  const OperationSummary = () => {
6
6
  return {
7
7
  Operation(operation, ctx) {
8
- utils_1.validateDefinedAndNonEmpty('summary', operation, ctx);
8
+ (0, utils_1.validateDefinedAndNonEmpty)('summary', operation, ctx);
9
9
  },
10
10
  };
11
11
  };
@@ -17,7 +17,7 @@ const PathSegmentPlural = (opts) => {
17
17
  for (const pathSegment of pathSegments) {
18
18
  if (exceptions && exceptions.includes(pathSegment))
19
19
  continue;
20
- if (!utils_1.isPathParameter(pathSegment) && utils_1.isSingular(pathSegment)) {
20
+ if (!(0, utils_1.isPathParameter)(pathSegment) && (0, utils_1.isSingular)(pathSegment)) {
21
21
  report({
22
22
  message: `path segment \`${pathSegment}\` should be plural.`,
23
23
  location: location.key(),
@@ -9,8 +9,8 @@ const ResponseContainsHeader = (options) => {
9
9
  Response: {
10
10
  enter: (response, { report, location, key }) => {
11
11
  const expectedHeaders = names[key] ||
12
- names[utils_1.getMatchingStatusCodeRange(key)] ||
13
- names[utils_1.getMatchingStatusCodeRange(key).toLowerCase()] ||
12
+ names[(0, utils_1.getMatchingStatusCodeRange)(key)] ||
13
+ names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] ||
14
14
  [];
15
15
  for (const expectedHeader of expectedHeaders) {
16
16
  if (!(response === null || response === void 0 ? void 0 : response.headers) ||
@@ -18,7 +18,7 @@ const SpecStrictRefs = () => {
18
18
  return {
19
19
  any(_node, { report, rawNode, rawLocation, type }) {
20
20
  const shouldCheck = !nodesToSkip.includes(type.name);
21
- if (shouldCheck && ref_utils_1.isRef(rawNode)) {
21
+ if (shouldCheck && (0, ref_utils_1.isRef)(rawNode)) {
22
22
  report({
23
23
  message: 'Field $ref is not expected here.',
24
24
  location: rawLocation.child('$ref').key(),
@@ -9,7 +9,7 @@ const Spec = () => {
9
9
  return {
10
10
  any(node, { report, type, location, rawLocation, key, resolve, ignoreNextVisitorsOnNode }) {
11
11
  var _a, _b, _c, _d, _e, _f;
12
- const nodeType = utils_1.oasTypeOf(node);
12
+ const nodeType = (0, utils_1.oasTypeOf)(node);
13
13
  const refLocation = rawLocation !== location ? rawLocation : undefined;
14
14
  if (type.items) {
15
15
  if (nodeType !== 'array') {
@@ -43,7 +43,7 @@ const Spec = () => {
43
43
  }
44
44
  }
45
45
  const allowed = (_a = type.allowed) === null || _a === void 0 ? void 0 : _a.call(type, node);
46
- if (allowed && utils_2.isPlainObject(node)) {
46
+ if (allowed && (0, utils_2.isPlainObject)(node)) {
47
47
  for (const propName in node) {
48
48
  if (allowed.includes(propName) ||
49
49
  (type.extensionsPrefix && propName.startsWith(type.extensionsPrefix)) ||
@@ -80,17 +80,17 @@ const Spec = () => {
80
80
  propType = type.additionalProperties;
81
81
  if (typeof propType === 'function')
82
82
  propType = propType(propValue, propName);
83
- if (types_1.isNamedType(propType)) {
83
+ if ((0, types_1.isNamedType)(propType)) {
84
84
  continue; // do nothing for named schema, it is executed with the next any call
85
85
  }
86
86
  const propSchema = propType;
87
- const propValueType = utils_1.oasTypeOf(propValue);
87
+ const propValueType = (0, utils_1.oasTypeOf)(propValue);
88
88
  if (propSchema === undefined) {
89
89
  if (propName.startsWith('x-'))
90
90
  continue;
91
91
  report({
92
92
  message: `Property \`${propName}\` is not expected here.`,
93
- suggest: utils_1.getSuggest(propName, Object.keys(type.properties)),
93
+ suggest: (0, utils_1.getSuggest)(propName, Object.keys(type.properties)),
94
94
  from: refLocation,
95
95
  location: propLocation.key(),
96
96
  });
@@ -99,24 +99,24 @@ const Spec = () => {
99
99
  if (propSchema === null) {
100
100
  continue; // just defined, no validation
101
101
  }
102
- if (propSchema.resolvable !== false && ref_utils_1.isRef(propValue)) {
102
+ if (propSchema.resolvable !== false && (0, ref_utils_1.isRef)(propValue)) {
103
103
  propValue = resolve(propValue).node;
104
104
  }
105
105
  if (propSchema.items && ((_c = propSchema.items) === null || _c === void 0 ? void 0 : _c.enum) && Array.isArray(propValue)) {
106
106
  for (let i = 0; i < propValue.length; i++) {
107
- utils_1.validateSchemaEnumType((_d = propSchema.items) === null || _d === void 0 ? void 0 : _d.enum, propValue[i], propName, refLocation, {
107
+ (0, utils_1.validateSchemaEnumType)((_d = propSchema.items) === null || _d === void 0 ? void 0 : _d.enum, propValue[i], propName, refLocation, {
108
108
  report,
109
109
  location: location.child([propName, i]),
110
110
  });
111
111
  }
112
112
  }
113
113
  if (propSchema.enum) {
114
- utils_1.validateSchemaEnumType(propSchema.enum, propValue, propName, refLocation, {
114
+ (0, utils_1.validateSchemaEnumType)(propSchema.enum, propValue, propName, refLocation, {
115
115
  report,
116
116
  location: location.child([propName]),
117
117
  });
118
118
  }
119
- else if (propSchema.type && !utils_1.matchesJsonSchemaType(propValue, propSchema.type, false)) {
119
+ else if (propSchema.type && !(0, utils_1.matchesJsonSchemaType)(propValue, propSchema.type, false)) {
120
120
  report({
121
121
  message: `Expected type \`${propSchema.type}\` but got \`${propValueType}\`.`,
122
122
  from: refLocation,
@@ -128,9 +128,9 @@ const Spec = () => {
128
128
  const itemsType = (_f = propSchema.items) === null || _f === void 0 ? void 0 : _f.type;
129
129
  for (let i = 0; i < propValue.length; i++) {
130
130
  const item = propValue[i];
131
- if (!utils_1.matchesJsonSchemaType(item, itemsType, false)) {
131
+ if (!(0, utils_1.matchesJsonSchemaType)(item, itemsType, false)) {
132
132
  report({
133
- message: `Expected type \`${itemsType}\` but got \`${utils_1.oasTypeOf(item)}\`.`,
133
+ message: `Expected type \`${itemsType}\` but got \`${(0, utils_1.oasTypeOf)(item)}\`.`,
134
134
  from: refLocation,
135
135
  location: propLocation.child([i]),
136
136
  });
@@ -5,7 +5,7 @@ const utils_1 = require("../utils");
5
5
  const TagDescription = () => {
6
6
  return {
7
7
  Tag(tag, ctx) {
8
- utils_1.validateDefinedAndNonEmpty('description', tag, ctx);
8
+ (0, utils_1.validateDefinedAndNonEmpty)('description', tag, ctx);
9
9
  },
10
10
  };
11
11
  };
@@ -1,5 +1,5 @@
1
1
  import { Oas2Rule } from '../../visitors';
2
- export declare type BooleanParameterPrefixesOptions = {
2
+ export type BooleanParameterPrefixesOptions = {
3
3
  prefixes?: string[];
4
4
  };
5
5
  export declare const BooleanParameterPrefixes: Oas2Rule;
@@ -1,47 +1,3 @@
1
- import { Oas2Rule } from '../../visitors';
2
- export declare const rules: {
3
- spec: Oas2Rule;
4
- 'no-invalid-schema-examples': any;
5
- 'no-invalid-parameter-examples': any;
6
- 'info-contact': Oas2Rule;
7
- 'info-license': Oas2Rule;
8
- 'info-license-url': Oas2Rule;
9
- 'tag-description': Oas2Rule;
10
- 'tags-alphabetical': Oas2Rule;
11
- 'paths-kebab-case': Oas2Rule;
12
- 'no-enum-type-mismatch': Oas2Rule;
13
- 'boolean-parameter-prefixes': Oas2Rule;
14
- 'no-path-trailing-slash': Oas2Rule;
15
- 'operation-2xx-response': Oas2Rule;
16
- 'operation-4xx-response': Oas2Rule;
17
- assertions: Oas2Rule;
18
- 'operation-operationId-unique': Oas2Rule;
19
- 'operation-parameters-unique': Oas2Rule;
20
- 'path-parameters-defined': Oas2Rule;
21
- 'operation-tag-defined': Oas2Rule;
22
- 'path-declaration-must-exist': Oas2Rule;
23
- 'operation-operationId-url-safe': Oas2Rule;
24
- 'operation-operationId': Oas2Rule;
25
- 'operation-summary': Oas2Rule;
26
- 'operation-description': Oas2Rule;
27
- 'path-not-include-query': Oas2Rule;
28
- 'path-params-defined': Oas2Rule;
29
- 'parameter-description': Oas2Rule;
30
- 'operation-singular-tag': Oas2Rule;
31
- 'security-defined': Oas2Rule;
32
- 'no-unresolved-refs': Oas2Rule;
33
- 'no-identical-paths': Oas2Rule;
34
- 'no-ambiguous-paths': Oas2Rule;
35
- 'path-http-verbs-order': Oas2Rule;
36
- 'no-http-verbs-in-paths': Oas2Rule;
37
- 'path-excludes-patterns': Oas2Rule;
38
- 'request-mime-type': Oas2Rule;
39
- 'response-mime-type': Oas2Rule;
40
- 'path-segment-plural': Oas2Rule;
41
- 'response-contains-header': Oas2Rule;
42
- 'response-contains-property': Oas2Rule;
43
- 'scalar-property-missing-example': import("../../visitors").Oas3Rule | Oas2Rule;
44
- 'required-string-property-missing-min-length': import("../../visitors").Oas3Rule;
45
- 'spec-strict-refs': import("../../visitors").Oas3Rule | Oas2Rule;
46
- };
1
+ import type { Oas2RuleSet } from 'core/src/oas-types';
2
+ export declare const rules: Oas2RuleSet<'built-in'>;
47
3
  export declare const preprocessors: {};
@@ -5,11 +5,11 @@ const utils_1 = require("../../utils");
5
5
  const RequestMimeType = ({ allowedValues }) => {
6
6
  return {
7
7
  Root(root, ctx) {
8
- utils_1.validateMimeType({ type: 'consumes', value: root }, ctx, allowedValues);
8
+ (0, utils_1.validateMimeType)({ type: 'consumes', value: root }, ctx, allowedValues);
9
9
  },
10
10
  Operation: {
11
11
  leave(operation, ctx) {
12
- utils_1.validateMimeType({ type: 'consumes', value: operation }, ctx, allowedValues);
12
+ (0, utils_1.validateMimeType)({ type: 'consumes', value: operation }, ctx, allowedValues);
13
13
  },
14
14
  },
15
15
  };
@@ -19,8 +19,8 @@ const ResponseContainsProperty = (options) => {
19
19
  if (schema.type !== 'object')
20
20
  return;
21
21
  const expectedProperties = names[key] ||
22
- names[utils_1.getMatchingStatusCodeRange(key)] ||
23
- names[utils_1.getMatchingStatusCodeRange(key).toLowerCase()] ||
22
+ names[(0, utils_1.getMatchingStatusCodeRange)(key)] ||
23
+ names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] ||
24
24
  [];
25
25
  for (const expectedProperty of expectedProperties) {
26
26
  if (!((_a = schema.properties) === null || _a === void 0 ? void 0 : _a[expectedProperty])) {