@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
package/lib/walk.js CHANGED
@@ -33,9 +33,9 @@ function walkDocument(opts) {
33
33
  function walkNode(node, type, location, parent, key) {
34
34
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
35
35
  const resolve = (ref, from = currentLocation.source.absoluteRef) => {
36
- if (!ref_utils_1.isRef(ref))
36
+ if (!(0, ref_utils_1.isRef)(ref))
37
37
  return { location, node: ref };
38
- const refId = resolve_1.makeRefId(from, ref.$ref);
38
+ const refId = (0, resolve_1.makeRefId)(from, ref.$ref);
39
39
  const resolvedRef = resolvedRefMap.get(refId);
40
40
  if (!resolvedRef) {
41
41
  return {
@@ -55,7 +55,7 @@ function walkDocument(opts) {
55
55
  let currentLocation = location;
56
56
  const { node: resolvedNode, location: resolvedLocation, error } = resolve(node);
57
57
  const enteredContexts = new Set();
58
- if (ref_utils_1.isRef(node)) {
58
+ if ((0, ref_utils_1.isRef)(node)) {
59
59
  const refEnterVisitors = normalizedVisitors.ref.enter;
60
60
  for (const { visit: visitor, ruleId, severity, context } of refEnterVisitors) {
61
61
  enteredContexts.add(context);
@@ -120,10 +120,10 @@ function walkDocument(opts) {
120
120
  rawNode: node,
121
121
  })))) !== null && _k !== void 0 ? _k : false,
122
122
  };
123
- context.activatedOn = utils_1.pushStack(context.activatedOn, activatedOn);
123
+ context.activatedOn = (0, utils_1.pushStack)(context.activatedOn, activatedOn);
124
124
  let ctx = context.parent;
125
125
  while (ctx) {
126
- ctx.activatedOn.value.nextLevelTypeActivated = utils_1.pushStack(ctx.activatedOn.value.nextLevelTypeActivated, type);
126
+ ctx.activatedOn.value.nextLevelTypeActivated = (0, utils_1.pushStack)(ctx.activatedOn.value.nextLevelTypeActivated, type);
127
127
  ctx = ctx.parent;
128
128
  }
129
129
  if (!activatedOn.skipped) {
@@ -154,7 +154,7 @@ function walkDocument(opts) {
154
154
  else if (type.extensionsPrefix) {
155
155
  props.push(...Object.keys(resolvedNode).filter((k) => k.startsWith(type.extensionsPrefix)));
156
156
  }
157
- if (ref_utils_1.isRef(node)) {
157
+ if ((0, ref_utils_1.isRef)(node)) {
158
158
  props.push(...Object.keys(node).filter((k) => k !== '$ref' && !props.includes(k))); // properties on the same level as $ref
159
159
  }
160
160
  for (const propName of props) {
@@ -174,14 +174,14 @@ function walkDocument(opts) {
174
174
  propName.startsWith(type.extensionsPrefix)) {
175
175
  propType = types_1.SpecExtension;
176
176
  }
177
- if (!types_1.isNamedType(propType) && (propType === null || propType === void 0 ? void 0 : propType.directResolveAs)) {
177
+ if (!(0, types_1.isNamedType)(propType) && (propType === null || propType === void 0 ? void 0 : propType.directResolveAs)) {
178
178
  propType = propType.directResolveAs;
179
179
  value = { $ref: value };
180
180
  }
181
181
  if (propType && propType.name === undefined && propType.resolvable !== false) {
182
182
  propType = { name: 'scalar', properties: {} };
183
183
  }
184
- if (!types_1.isNamedType(propType) || (propType.name === 'scalar' && !ref_utils_1.isRef(value))) {
184
+ if (!(0, types_1.isNamedType)(propType) || (propType.name === 'scalar' && !(0, ref_utils_1.isRef)(value))) {
185
185
  continue;
186
186
  }
187
187
  walkNode(value, propType, loc.child([propName]), resolvedNode, propName);
@@ -195,11 +195,11 @@ function walkDocument(opts) {
195
195
  context.seen.delete(resolvedNode);
196
196
  }
197
197
  else {
198
- context.activatedOn = utils_1.popStack(context.activatedOn);
198
+ context.activatedOn = (0, utils_1.popStack)(context.activatedOn);
199
199
  if (context.parent) {
200
200
  let ctx = context.parent;
201
201
  while (ctx) {
202
- ctx.activatedOn.value.nextLevelTypeActivated = utils_1.popStack(ctx.activatedOn.value.nextLevelTypeActivated);
202
+ ctx.activatedOn.value.nextLevelTypeActivated = (0, utils_1.popStack)(ctx.activatedOn.value.nextLevelTypeActivated);
203
203
  ctx = ctx.parent;
204
204
  }
205
205
  }
@@ -212,7 +212,7 @@ function walkDocument(opts) {
212
212
  }
213
213
  }
214
214
  currentLocation = location;
215
- if (ref_utils_1.isRef(node)) {
215
+ if ((0, ref_utils_1.isRef)(node)) {
216
216
  const refLeaveVisitors = normalizedVisitors.ref.leave;
217
217
  for (const { visit: visitor, ruleId, severity, context } of refLeaveVisitors) {
218
218
  if (enteredContexts.has(context)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -52,6 +52,6 @@
52
52
  "@types/minimatch": "^3.0.5",
53
53
  "@types/node-fetch": "^2.5.7",
54
54
  "@types/pluralize": "^0.0.29",
55
- "typescript": "^4.0.5"
55
+ "typescript": "^5.2.2"
56
56
  }
57
57
  }
@@ -27,11 +27,11 @@ describe('lint', () => {
27
27
  });
28
28
 
29
29
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
30
- Array [
31
- Object {
30
+ [
31
+ {
32
32
  "from": undefined,
33
- "location": Array [
34
- Object {
33
+ "location": [
34
+ {
35
35
  "pointer": "#/info/license",
36
36
  "reportOnKey": false,
37
37
  "source": "/test/spec.yaml",
@@ -40,7 +40,7 @@ describe('lint', () => {
40
40
  "message": "Expected type \`License\` (object) but got \`string\`",
41
41
  "ruleId": "spec",
42
42
  "severity": "error",
43
- "suggest": Array [],
43
+ "suggest": [],
44
44
  },
45
45
  ]
46
46
  `);
@@ -56,11 +56,11 @@ describe('lint', () => {
56
56
 
57
57
  expect(replaceSourceWithRef(results, path.join(__dirname, 'fixtures/lint/')))
58
58
  .toMatchInlineSnapshot(`
59
- Array [
60
- Object {
59
+ [
60
+ {
61
61
  "from": undefined,
62
- "location": Array [
63
- Object {
62
+ "location": [
63
+ {
64
64
  "pointer": "#/info/license",
65
65
  "reportOnKey": false,
66
66
  "source": "openapi.yaml",
@@ -69,7 +69,7 @@ describe('lint', () => {
69
69
  "message": "Expected type \`License\` (object) but got \`string\`",
70
70
  "ruleId": "spec",
71
71
  "severity": "error",
72
- "suggest": Array [],
72
+ "suggest": [],
73
73
  },
74
74
  ]
75
75
  `);
@@ -125,11 +125,11 @@ describe('lint', () => {
125
125
  const results = await lintConfig({ document });
126
126
 
127
127
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
128
- Array [
129
- Object {
128
+ [
129
+ {
130
130
  "from": undefined,
131
- "location": Array [
132
- Object {
131
+ "location": [
132
+ {
133
133
  "pointer": "#/eme",
134
134
  "reportOnKey": true,
135
135
  "source": "",
@@ -138,17 +138,17 @@ describe('lint', () => {
138
138
  "message": "Property \`eme\` is not expected here.",
139
139
  "ruleId": "configuration spec",
140
140
  "severity": "error",
141
- "suggest": Array [
141
+ "suggest": [
142
142
  "theme",
143
143
  "env",
144
144
  "seo",
145
145
  "sso",
146
146
  ],
147
147
  },
148
- Object {
148
+ {
149
149
  "from": undefined,
150
- "location": Array [
151
- Object {
150
+ "location": [
151
+ {
152
152
  "pointer": "#/openapi",
153
153
  "reportOnKey": true,
154
154
  "source": "",
@@ -157,12 +157,12 @@ describe('lint', () => {
157
157
  "message": "Property \`openapi\` is not expected here.",
158
158
  "ruleId": "configuration spec",
159
159
  "severity": "error",
160
- "suggest": Array [],
160
+ "suggest": [],
161
161
  },
162
- Object {
162
+ {
163
163
  "from": undefined,
164
- "location": Array [
165
- Object {
164
+ "location": [
165
+ {
166
166
  "pointer": "#/apis",
167
167
  "reportOnKey": false,
168
168
  "source": "",
@@ -171,7 +171,7 @@ describe('lint', () => {
171
171
  "message": "Expected type \`ConfigApis\` (object) but got \`string\`",
172
172
  "ruleId": "configuration spec",
173
173
  "severity": "error",
174
- "suggest": Array [],
174
+ "suggest": [],
175
175
  },
176
176
  ]
177
177
  `);
@@ -191,11 +191,11 @@ describe('lint', () => {
191
191
  const results = await lintConfig({ document });
192
192
 
193
193
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
194
- Array [
195
- Object {
194
+ [
195
+ {
196
196
  "from": undefined,
197
- "location": Array [
198
- Object {
197
+ "location": [
198
+ {
199
199
  "pointer": "#/api",
200
200
  "reportOnKey": true,
201
201
  "source": "",
@@ -204,7 +204,7 @@ describe('lint', () => {
204
204
  "message": "Property \`api\` is not expected here.",
205
205
  "ruleId": "configuration spec",
206
206
  "severity": "error",
207
- "suggest": Array [
207
+ "suggest": [
208
208
  "apis",
209
209
  "seo",
210
210
  "sso",
@@ -231,11 +231,11 @@ describe('lint', () => {
231
231
  const results = await lintConfig({ document });
232
232
 
233
233
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
234
- Array [
235
- Object {
234
+ [
235
+ {
236
236
  "from": undefined,
237
- "location": Array [
238
- Object {
237
+ "location": [
238
+ {
239
239
  "pointer": "#/referenceDocs",
240
240
  "reportOnKey": true,
241
241
  "source": "",
@@ -244,7 +244,7 @@ describe('lint', () => {
244
244
  "message": "Property \`referenceDocs\` is not expected here.",
245
245
  "ruleId": "configuration spec",
246
246
  "severity": "error",
247
- "suggest": Array [],
247
+ "suggest": [],
248
248
  },
249
249
  ]
250
250
  `);
@@ -266,11 +266,11 @@ describe('lint', () => {
266
266
  const results = await lintConfig({ document });
267
267
 
268
268
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
269
- Array [
270
- Object {
269
+ [
270
+ {
271
271
  "from": undefined,
272
- "location": Array [
273
- Object {
272
+ "location": [
273
+ {
274
274
  "pointer": "#/apis/main/plugins",
275
275
  "reportOnKey": true,
276
276
  "source": "",
@@ -279,7 +279,7 @@ describe('lint', () => {
279
279
  "message": "Property \`plugins\` is not expected here.",
280
280
  "ruleId": "configuration spec",
281
281
  "severity": "error",
282
- "suggest": Array [],
282
+ "suggest": [],
283
283
  },
284
284
  ]
285
285
  `);
@@ -323,7 +323,7 @@ describe('lint', () => {
323
323
  config: await makeConfig({ spec: 'error' }),
324
324
  });
325
325
 
326
- expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
326
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
327
327
  });
328
328
 
329
329
  it('detect OpenAPI should throw an error when version is not string', () => {
@@ -402,7 +402,7 @@ describe('lint', () => {
402
402
  config: await makeConfig({ spec: 'error' }),
403
403
  });
404
404
 
405
- expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
405
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
406
406
  });
407
407
 
408
408
  it('should ignore error because ignore file passed', async () => {
@@ -1,4 +1,10 @@
1
- import { normalizeVisitors, VisitorLevelContext } from '../visitors';
1
+ import {
2
+ BaseVisitor,
3
+ NestedVisitObject,
4
+ normalizeVisitors,
5
+ RuleInstanceConfig,
6
+ VisitorLevelContext,
7
+ } from '../visitors';
2
8
  import { Oas3RuleSet } from '../oas-types';
3
9
  import { Oas3Types } from '../types/oas3';
4
10
  import { normalizeTypes } from '../types';
@@ -25,7 +31,10 @@ describe('Normalize visitors', () => {
25
31
  }))
26
32
  );
27
33
 
28
- const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
34
+ const normalized = normalizeVisitors(
35
+ visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
36
+ normalizeTypes(Oas3Types)
37
+ );
29
38
  expect(normalized).toBeDefined();
30
39
  expect(normalized.Schema.enter).toHaveLength(1);
31
40
  expect(normalized.Schema.enter[0].visit).toEqual(schemaEnter);
@@ -69,7 +78,10 @@ describe('Normalize visitors', () => {
69
78
  }))
70
79
  );
71
80
 
72
- const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
81
+ const normalized = normalizeVisitors(
82
+ visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
83
+ normalizeTypes(Oas3Types)
84
+ );
73
85
  expect(normalized).toBeDefined();
74
86
  expect(normalized.Info.enter).toHaveLength(1);
75
87
 
@@ -107,7 +119,10 @@ describe('Normalize visitors', () => {
107
119
  }))
108
120
  );
109
121
 
110
- const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
122
+ const normalized = normalizeVisitors(
123
+ visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
124
+ normalizeTypes(Oas3Types)
125
+ );
111
126
  expect(normalized).toBeDefined();
112
127
  expect(normalized.PathItem.enter).toHaveLength(1);
113
128
  expect(normalized.Operation.enter).toHaveLength(1);
@@ -142,7 +157,10 @@ describe('Normalize visitors', () => {
142
157
  }))
143
158
  );
144
159
 
145
- const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types));
160
+ const normalized = normalizeVisitors(
161
+ visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
162
+ normalizeTypes(Oas3Types)
163
+ );
146
164
  expect(normalized).toBeDefined();
147
165
  expect(normalized.Parameter.enter).toHaveLength(2);
148
166
  expect(normalized.Parameter.enter[0].visit).toStrictEqual(operationParam);
@@ -9,8 +9,8 @@ describe('ref-utils', () => {
9
9
  it(`should unescape refs with '/'`, () => {
10
10
  const reference = 'somefile.yaml#/components/schemas/scope~1domain-schema';
11
11
  expect(parseRef(reference)).toMatchInlineSnapshot(`
12
- Object {
13
- "pointer": Array [
12
+ {
13
+ "pointer": [
14
14
  "components",
15
15
  "schemas",
16
16
  "scope/domain-schema",
@@ -23,8 +23,8 @@ describe('ref-utils', () => {
23
23
  it(`should unescape refs with '~'`, () => {
24
24
  const reference = 'somefile.yaml#/components/schemas/complex~0name';
25
25
  expect(parseRef(reference)).toMatchInlineSnapshot(`
26
- Object {
27
- "pointer": Array [
26
+ {
27
+ "pointer": [
28
28
  "components",
29
29
  "schemas",
30
30
  "complex~name",
@@ -37,8 +37,8 @@ describe('ref-utils', () => {
37
37
  it(`should unescape complex urlencoded paths`, () => {
38
38
  const referene = 'somefile.yaml#/components/schemas/scope%2Fcomplex~name';
39
39
  expect(parseRef(referene)).toMatchInlineSnapshot(`
40
- Object {
41
- "pointer": Array [
40
+ {
41
+ "pointer": [
42
42
  "components",
43
43
  "schemas",
44
44
  "scope/complex~name",
@@ -93,7 +93,7 @@ describe('ref-utils', () => {
93
93
  config: new StyleguideConfig({}),
94
94
  });
95
95
 
96
- expect(result).toMatchInlineSnapshot(`Array []`);
96
+ expect(result).toMatchInlineSnapshot(`[]`);
97
97
  });
98
98
 
99
99
  describe('refBaseName', () => {
@@ -48,25 +48,25 @@ describe('Resolve http-headers', () => {
48
48
 
49
49
  expect(fetchMock).toBeCalledTimes(3);
50
50
  expect(fetchMock.mock.calls).toMatchInlineSnapshot(`
51
- Array [
52
- Array [
51
+ [
52
+ [
53
53
  "https://example.com/test.yaml",
54
- Object {
55
- "headers": Object {
54
+ {
55
+ "headers": {
56
56
  "X_TEST": "123",
57
57
  },
58
58
  },
59
59
  ],
60
- Array [
60
+ [
61
61
  "https://sample.com/test.yaml",
62
- Object {
63
- "headers": Object {},
62
+ {
63
+ "headers": {},
64
64
  },
65
65
  ],
66
- Array [
66
+ [
67
67
  "https://sample.com/test/a/test.yaml",
68
- Object {
69
- "headers": Object {
68
+ {
69
+ "headers": {
70
70
  "X_TEST": "321",
71
71
  },
72
72
  },
@@ -33,7 +33,7 @@ describe('collect refs', () => {
33
33
  expect(Array.from(resolvedRefs.keys())).toMatchInlineSnapshot(
34
34
  [`foobar.yaml::#/defs/info`],
35
35
  `
36
- Array [
36
+ [
37
37
  "foobar.yaml::#/defs/info",
38
38
  ]
39
39
  `
@@ -198,7 +198,7 @@ describe('collect refs', () => {
198
198
  .map((ref) => ref.substring(cwd.length + 1))
199
199
  .sort()
200
200
  ).toMatchInlineSnapshot(`
201
- Array [
201
+ [
202
202
  "openapi-with-back.yaml::./schemas/type-a.yaml#/",
203
203
  "openapi-with-back.yaml::./schemas/type-b.yaml#/",
204
204
  "schemas/type-a.yaml::../openapi-with-back.yaml#/components/schemas/TypeB",
@@ -214,19 +214,19 @@ describe('collect refs', () => {
214
214
  return getKey(firstEl).localeCompare(getKey(secondEl));
215
215
  })
216
216
  ).toMatchInlineSnapshot(`
217
- Array [
218
- Object {
219
- "allOf": Array [
220
- Object {
221
- "properties": Object {
222
- "integration_type": Object {
217
+ [
218
+ {
219
+ "allOf": [
220
+ {
221
+ "properties": {
222
+ "integration_type": {
223
223
  "$ref": "../openapi-with-back.yaml#/components/schemas/TypeB",
224
224
  },
225
- "name": Object {
225
+ "name": {
226
226
  "type": "string",
227
227
  },
228
228
  },
229
- "required": Array [
229
+ "required": [
230
230
  "name",
231
231
  "integration_type",
232
232
  ],
@@ -234,8 +234,8 @@ describe('collect refs', () => {
234
234
  },
235
235
  ],
236
236
  },
237
- Object {
238
- "enum": Array [
237
+ {
238
+ "enum": [
239
239
  "webhook",
240
240
  "api_key",
241
241
  "sftp",
@@ -243,8 +243,8 @@ describe('collect refs', () => {
243
243
  ],
244
244
  "type": "string",
245
245
  },
246
- Object {
247
- "enum": Array [
246
+ {
247
+ "enum": [
248
248
  "webhook",
249
249
  "api_key",
250
250
  "sftp",
@@ -270,7 +270,7 @@ describe('collect refs', () => {
270
270
  expect(resolvedRefs).toBeDefined();
271
271
  expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
272
272
  .toMatchInlineSnapshot(`
273
- Array [
273
+ [
274
274
  "openapi.yaml::#/components/schemas/Local",
275
275
  "openapi.yaml::#/components/schemas/Local/properties/string",
276
276
  "openapi.yaml::./External.yaml#/properties/string",
@@ -281,62 +281,62 @@ describe('collect refs', () => {
281
281
  `);
282
282
 
283
283
  expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(`
284
- Array [
285
- Object {
286
- "properties": Object {
287
- "localCircular": Object {
284
+ [
285
+ {
286
+ "properties": {
287
+ "localCircular": {
288
288
  "$ref": "#/components/schemas/Local",
289
289
  },
290
- "number": Object {
290
+ "number": {
291
291
  "type": "number",
292
292
  },
293
- "string": Object {
293
+ "string": {
294
294
  "type": "string",
295
295
  },
296
296
  },
297
297
  },
298
- Object {
298
+ {
299
299
  "type": "string",
300
300
  },
301
- Object {
301
+ {
302
302
  "type": "string",
303
303
  },
304
- Object {
305
- "properties": Object {
306
- "external": Object {
304
+ {
305
+ "properties": {
306
+ "external": {
307
307
  "$ref": "./External2.yaml",
308
308
  },
309
- "number": Object {
309
+ "number": {
310
310
  "type": "number",
311
311
  },
312
- "string": Object {
312
+ "string": {
313
313
  "type": "string",
314
314
  },
315
- "unknown": Object {
315
+ "unknown": {
316
316
  "type": "string",
317
317
  },
318
318
  },
319
319
  "type": "object",
320
320
  },
321
- Object {
322
- "properties": Object {
323
- "circularParent": Object {
321
+ {
322
+ "properties": {
323
+ "circularParent": {
324
324
  "$ref": "./External.yaml#/properties",
325
325
  },
326
326
  },
327
327
  "type": "object",
328
328
  },
329
- Object {
330
- "external": Object {
329
+ {
330
+ "external": {
331
331
  "$ref": "./External2.yaml",
332
332
  },
333
- "number": Object {
333
+ "number": {
334
334
  "type": "number",
335
335
  },
336
- "string": Object {
336
+ "string": {
337
337
  "type": "string",
338
338
  },
339
- "unknown": Object {
339
+ "unknown": {
340
340
  "type": "string",
341
341
  },
342
342
  },
@@ -366,12 +366,12 @@ describe('collect refs', () => {
366
366
  // expect(resolvedRefs.size).toEqual(2);
367
367
  expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
368
368
  .toMatchInlineSnapshot(`
369
- Array [
369
+ [
370
370
  "openapi-with-md-description.yaml::./description.md",
371
371
  ]
372
372
  `);
373
373
  expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(`
374
- Array [
374
+ [
375
375
  "# Hello World
376
376
 
377
377
  Lorem ipsum