@redocly/openapi-core 1.0.0-beta.105 → 1.0.0-beta.108

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 (240) hide show
  1. package/README.md +4 -4
  2. package/__tests__/utils.ts +5 -5
  3. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
  4. package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
  5. package/lib/benchmark/utils.d.ts +2 -2
  6. package/lib/benchmark/utils.js +2 -2
  7. package/lib/bundle.d.ts +2 -2
  8. package/lib/bundle.js +7 -4
  9. package/lib/config/all.d.ts +2 -2
  10. package/lib/config/all.js +3 -3
  11. package/lib/config/builtIn.d.ts +2 -2
  12. package/lib/config/builtIn.js +2 -2
  13. package/lib/config/config-resolvers.d.ts +5 -5
  14. package/lib/config/config-resolvers.js +70 -49
  15. package/lib/config/config.d.ts +8 -10
  16. package/lib/config/config.js +10 -7
  17. package/lib/config/load.d.ts +7 -0
  18. package/lib/config/load.js +18 -10
  19. package/lib/config/minimal.d.ts +2 -2
  20. package/lib/config/minimal.js +5 -4
  21. package/lib/config/recommended.d.ts +2 -2
  22. package/lib/config/recommended.js +5 -4
  23. package/lib/config/rules.d.ts +3 -3
  24. package/lib/config/rules.js +1 -1
  25. package/lib/config/types.d.ts +23 -19
  26. package/lib/config/utils.d.ts +5 -5
  27. package/lib/config/utils.js +48 -31
  28. package/lib/decorators/common/registry-dependencies.js +1 -1
  29. package/lib/decorators/common/remove-x-internal.js +2 -2
  30. package/lib/env.d.ts +3 -0
  31. package/lib/env.js +8 -0
  32. package/lib/format/codeframes.js +16 -10
  33. package/lib/format/format.js +29 -27
  34. package/lib/index.d.ts +5 -5
  35. package/lib/index.js +4 -2
  36. package/lib/js-yaml/index.js +2 -6
  37. package/lib/lint.d.ts +2 -2
  38. package/lib/lint.js +16 -6
  39. package/lib/logger.d.ts +10 -0
  40. package/lib/logger.js +31 -0
  41. package/lib/output.d.ts +3 -0
  42. package/lib/output.js +9 -0
  43. package/lib/redocly/index.js +10 -9
  44. package/lib/redocly/registry-api-types.d.ts +28 -30
  45. package/lib/redocly/registry-api.d.ts +4 -3
  46. package/lib/redocly/registry-api.js +9 -4
  47. package/lib/ref-utils.js +2 -1
  48. package/lib/resolve.d.ts +1 -1
  49. package/lib/resolve.js +1 -1
  50. package/lib/rules/ajv.d.ts +1 -1
  51. package/lib/rules/ajv.js +7 -7
  52. package/lib/rules/common/assertions/asserts.js +4 -4
  53. package/lib/rules/common/assertions/index.js +1 -1
  54. package/lib/rules/common/info-license-url.d.ts +1 -1
  55. package/lib/rules/common/info-license-url.js +5 -10
  56. package/lib/rules/common/info-license.d.ts +2 -0
  57. package/lib/rules/common/info-license.js +17 -0
  58. package/lib/rules/common/no-enum-type-mismatch.js +1 -3
  59. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  60. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  61. package/lib/rules/common/operation-operationId.js +1 -1
  62. package/lib/rules/common/operation-security-defined.js +1 -1
  63. package/lib/rules/common/path-not-include-query.js +1 -1
  64. package/lib/rules/common/paths-kebab-case.js +4 -1
  65. package/lib/rules/common/spec.js +3 -3
  66. package/lib/rules/oas2/index.js +4 -4
  67. package/lib/rules/oas2/remove-unused-components.js +5 -5
  68. package/lib/rules/oas3/index.js +6 -6
  69. package/lib/rules/oas3/no-empty-servers.js +1 -1
  70. package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
  71. package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
  72. package/lib/rules/oas3/{no-servers-empty-enum.js → no-server-variables-empty-enum.js} +4 -4
  73. package/lib/rules/oas3/no-unused-components.js +1 -1
  74. package/lib/rules/oas3/remove-unused-components.js +5 -5
  75. package/lib/rules/other/stats.js +43 -14
  76. package/lib/rules/utils.d.ts +3 -2
  77. package/lib/rules/utils.js +20 -5
  78. package/lib/types/index.d.ts +2 -2
  79. package/lib/types/redocly-yaml.js +9 -8
  80. package/lib/utils.d.ts +5 -0
  81. package/lib/utils.js +22 -5
  82. package/lib/visitors.d.ts +1 -1
  83. package/lib/visitors.js +2 -2
  84. package/lib/walk.d.ts +2 -1
  85. package/lib/walk.js +6 -3
  86. package/package.json +2 -2
  87. package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
  88. package/src/__tests__/bundle.test.ts +68 -34
  89. package/src/__tests__/codeframes.test.ts +13 -14
  90. package/src/__tests__/js-yaml.test.ts +6 -4
  91. package/src/__tests__/lint.test.ts +74 -6
  92. package/src/__tests__/logger-browser.test.ts +53 -0
  93. package/src/__tests__/logger.test.ts +47 -0
  94. package/src/__tests__/login.test.ts +2 -2
  95. package/src/__tests__/normalizeVisitors.test.ts +4 -4
  96. package/src/__tests__/output-browser.test.ts +18 -0
  97. package/src/__tests__/output.test.ts +15 -0
  98. package/src/__tests__/ref-utils.test.ts +13 -13
  99. package/src/__tests__/resolve-http.test.ts +1 -1
  100. package/src/__tests__/resolve.test.ts +14 -11
  101. package/src/__tests__/utils-browser.test.ts +11 -0
  102. package/src/__tests__/utils.test.ts +7 -0
  103. package/src/__tests__/walk.test.ts +48 -56
  104. package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
  105. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
  106. package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
  107. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -2
  108. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
  109. package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
  110. package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
  111. package/src/benchmark/benchmark.js +9 -5
  112. package/src/benchmark/utils.ts +5 -5
  113. package/src/bundle.ts +24 -20
  114. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +7 -5
  115. package/src/config/__tests__/config-resolvers.test.ts +123 -121
  116. package/src/config/__tests__/config.test.ts +111 -76
  117. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
  118. package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
  119. package/src/config/__tests__/load.test.ts +79 -1
  120. package/src/config/__tests__/resolve-plugins.test.ts +3 -3
  121. package/src/config/__tests__/utils.test.ts +83 -0
  122. package/src/config/all.ts +5 -6
  123. package/src/config/builtIn.ts +5 -5
  124. package/src/config/config-resolvers.ts +161 -96
  125. package/src/config/config.ts +15 -13
  126. package/src/config/load.ts +34 -11
  127. package/src/config/minimal.ts +7 -6
  128. package/src/config/recommended.ts +7 -6
  129. package/src/config/rules.ts +6 -6
  130. package/src/config/types.ts +28 -19
  131. package/src/config/utils.ts +78 -57
  132. package/src/decorators/__tests__/filter-out.test.ts +8 -4
  133. package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
  134. package/src/decorators/common/filters/filter-helper.ts +1 -1
  135. package/src/decorators/common/info-description-override.ts +1 -1
  136. package/src/decorators/common/operation-description-override.ts +1 -1
  137. package/src/decorators/common/registry-dependencies.ts +1 -1
  138. package/src/decorators/common/remove-x-internal.ts +4 -4
  139. package/src/decorators/common/tag-description-override.ts +1 -1
  140. package/src/env.ts +5 -0
  141. package/src/format/codeframes.ts +18 -12
  142. package/src/format/format.ts +37 -42
  143. package/src/index.ts +8 -7
  144. package/src/js-yaml/index.ts +4 -8
  145. package/src/lint.ts +22 -18
  146. package/src/logger.ts +34 -0
  147. package/src/oas-types.ts +1 -6
  148. package/src/output.ts +7 -0
  149. package/src/redocly/__tests__/redocly-client.test.ts +25 -19
  150. package/src/redocly/index.ts +12 -7
  151. package/src/redocly/registry-api-types.ts +27 -29
  152. package/src/redocly/registry-api.ts +22 -12
  153. package/src/ref-utils.ts +4 -3
  154. package/src/resolve.ts +11 -8
  155. package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
  156. package/src/rules/__tests__/utils.test.ts +160 -0
  157. package/src/rules/ajv.ts +7 -8
  158. package/src/rules/common/__tests__/info-description.test.ts +3 -3
  159. package/src/rules/common/__tests__/info-license.test.ts +2 -2
  160. package/src/rules/common/__tests__/license-url.test.ts +2 -2
  161. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
  162. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
  163. package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
  164. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
  165. package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
  166. package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
  167. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
  168. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
  169. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
  170. package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
  171. package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
  172. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
  173. package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
  174. package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
  175. package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
  176. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
  177. package/src/rules/common/__tests__/spec.test.ts +2 -2
  178. package/src/rules/common/__tests__/tag-description.test.ts +2 -2
  179. package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
  180. package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
  181. package/src/rules/common/assertions/asserts.ts +4 -4
  182. package/src/rules/common/assertions/index.ts +7 -7
  183. package/src/rules/common/info-license-url.ts +4 -9
  184. package/src/rules/common/info-license.ts +15 -0
  185. package/src/rules/common/no-ambiguous-paths.ts +1 -1
  186. package/src/rules/common/no-enum-type-mismatch.ts +12 -9
  187. package/src/rules/common/no-invalid-parameter-examples.ts +4 -4
  188. package/src/rules/common/no-invalid-schema-examples.ts +4 -4
  189. package/src/rules/common/operation-operationId.ts +1 -1
  190. package/src/rules/common/operation-parameters-unique.ts +2 -2
  191. package/src/rules/common/operation-security-defined.ts +1 -1
  192. package/src/rules/common/path-not-include-query.ts +1 -1
  193. package/src/rules/common/path-params-defined.ts +1 -1
  194. package/src/rules/common/paths-kebab-case.ts +4 -1
  195. package/src/rules/common/scalar-property-missing-example.ts +1 -1
  196. package/src/rules/common/spec.ts +12 -9
  197. package/src/rules/no-unresolved-refs.ts +1 -1
  198. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  199. package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
  200. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  201. package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
  202. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
  203. package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
  204. package/src/rules/oas2/index.ts +3 -3
  205. package/src/rules/oas2/remove-unused-components.ts +14 -9
  206. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  207. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +16 -16
  208. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
  209. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +13 -13
  210. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
  211. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
  212. package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
  213. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  214. package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
  215. package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
  216. package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
  217. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
  218. package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
  219. package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
  220. package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
  221. package/src/rules/oas3/index.ts +5 -5
  222. package/src/rules/oas3/no-empty-servers.ts +1 -1
  223. package/src/rules/oas3/no-invalid-media-type-examples.ts +14 -6
  224. package/src/rules/oas3/{no-servers-empty-enum.ts → no-server-variables-empty-enum.ts} +10 -11
  225. package/src/rules/oas3/no-unused-components.ts +1 -1
  226. package/src/rules/oas3/remove-unused-components.ts +21 -10
  227. package/src/rules/other/stats.ts +46 -17
  228. package/src/rules/utils.ts +20 -4
  229. package/src/types/index.ts +5 -5
  230. package/src/types/redocly-yaml.ts +9 -8
  231. package/src/typings/common.ts +9 -1
  232. package/src/typings/openapi.ts +1 -1
  233. package/src/utils.ts +26 -3
  234. package/src/visitors.ts +9 -9
  235. package/src/walk.ts +15 -11
  236. package/tsconfig.tsbuildinfo +1 -1
  237. package/lib/rules/common/license-url.d.ts +0 -2
  238. package/lib/rules/common/license-url.js +0 -12
  239. package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
  240. package/src/rules/common/license-url.ts +0 -10
@@ -23,7 +23,7 @@ describe('OpenAPI Schema', () => {
23
23
  expect(
24
24
  await validateDoc(source, {
25
25
  spec: 'error',
26
- }),
26
+ })
27
27
  ).toMatchInlineSnapshot(`Array []`);
28
28
  });
29
29
 
@@ -43,7 +43,7 @@ describe('OpenAPI Schema', () => {
43
43
  expect(
44
44
  await validateDoc(source, {
45
45
  spec: 'error',
46
- }),
46
+ })
47
47
  ).toMatchInlineSnapshot(`Array []`);
48
48
  });
49
49
 
@@ -61,7 +61,7 @@ describe('OpenAPI Schema', () => {
61
61
  expect(
62
62
  await validateDoc(source, {
63
63
  spec: 'error',
64
- }),
64
+ })
65
65
  ).toMatchInlineSnapshot(`
66
66
  Array [
67
67
  Object {
@@ -88,7 +88,7 @@ describe('OpenAPI Schema', () => {
88
88
  expect(
89
89
  await validateDoc(source, {
90
90
  spec: 'error',
91
- }),
91
+ })
92
92
  ).toMatchInlineSnapshot(`Array []`);
93
93
  });
94
94
 
@@ -114,7 +114,7 @@ describe('OpenAPI Schema', () => {
114
114
  expect(
115
115
  await validateDoc(source, {
116
116
  spec: 'error',
117
- }),
117
+ })
118
118
  ).toMatchInlineSnapshot(`
119
119
  Array [
120
120
  Object {
@@ -151,7 +151,7 @@ describe('OpenAPI Schema', () => {
151
151
  expect(
152
152
  await validateDoc(source, {
153
153
  'no-identical-paths': 'error',
154
- }),
154
+ })
155
155
  ).toMatchInlineSnapshot(`
156
156
  Array [
157
157
  Object {
@@ -188,7 +188,7 @@ describe('OpenAPI Schema', () => {
188
188
  expect(
189
189
  await validateDoc(source, {
190
190
  spec: 'error',
191
- }),
191
+ })
192
192
  ).toMatchInlineSnapshot(`Array []`);
193
193
  });
194
194
 
@@ -218,7 +218,7 @@ describe('OpenAPI Schema', () => {
218
218
  expect(
219
219
  await validateDoc(source, {
220
220
  spec: 'error',
221
- }),
221
+ })
222
222
  ).toMatchInlineSnapshot(`Array []`);
223
223
  });
224
224
 
@@ -239,7 +239,7 @@ describe('OpenAPI Schema', () => {
239
239
  expect(
240
240
  await validateDoc(source, {
241
241
  spec: 'error',
242
- }),
242
+ })
243
243
  ).toMatchInlineSnapshot(`Array []`);
244
244
  });
245
245
 
@@ -278,7 +278,7 @@ describe('OpenAPI Schema', () => {
278
278
  expect(
279
279
  await validateDoc(source, {
280
280
  spec: 'error',
281
- }),
281
+ })
282
282
  ).toMatchInlineSnapshot(`Array []`);
283
283
  });
284
284
  });
@@ -1,9 +1,9 @@
1
1
  import { outdent } from 'outdent';
2
2
  import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils';
3
3
  import { lintDocument } from '../../../../lint';
4
- import { LintConfig } from '../../../..';
4
+ import { StyleguideConfig } from '../../../..';
5
5
  import { BaseResolver } from '../../../../resolve';
6
- import { resolveLint } from '../../../../config';
6
+ import { resolveStyleguideConfig } from '../../../../config';
7
7
 
8
8
  describe('Referenceable scalars', () => {
9
9
  it('should not report $ref description', async () => {
@@ -17,22 +17,22 @@ describe('Referenceable scalars', () => {
17
17
  $ref: fixtures/description.md
18
18
  paths: {}
19
19
  `,
20
- __dirname + '/foobar.yaml',
20
+ __dirname + '/foobar.yaml'
21
21
  );
22
22
 
23
23
  const results = await lintDocument({
24
24
  externalRefResolver: new BaseResolver(),
25
25
  document,
26
- config: new LintConfig(
27
- await resolveLint({
28
- lintConfig: {
26
+ config: new StyleguideConfig(
27
+ await resolveStyleguideConfig({
28
+ styleguideConfig: {
29
29
  extends: [],
30
30
  rules: {
31
31
  spec: 'error',
32
32
  'no-unresolved-refs': 'error',
33
33
  },
34
34
  },
35
- }),
35
+ })
36
36
  ),
37
37
  });
38
38
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
@@ -54,22 +54,22 @@ describe('Referenceable scalars', () => {
54
54
  example:
55
55
  $ref: not $ref, example
56
56
  `,
57
- __dirname + '/foobar.yaml',
57
+ __dirname + '/foobar.yaml'
58
58
  );
59
59
 
60
60
  const results = await lintDocument({
61
61
  externalRefResolver: new BaseResolver(),
62
62
  document,
63
- config: new LintConfig(
64
- await resolveLint({
65
- lintConfig: {
63
+ config: new StyleguideConfig(
64
+ await resolveStyleguideConfig({
65
+ styleguideConfig: {
66
66
  extends: [],
67
67
  rules: {
68
68
  'no-unresolved-refs': 'error',
69
69
  },
70
70
  doNotResolveExamples: true,
71
71
  },
72
- }),
72
+ })
73
73
  ),
74
74
  });
75
75
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
@@ -24,7 +24,7 @@ describe('OpenAPI Schema', () => {
24
24
  expect(
25
25
  await validateDoc(source, {
26
26
  spec: 'error',
27
- }),
27
+ })
28
28
  ).toMatchInlineSnapshot(`Array []`);
29
29
  });
30
30
 
@@ -49,7 +49,7 @@ describe('OpenAPI Schema', () => {
49
49
  expect(
50
50
  await validateDoc(source, {
51
51
  spec: 'error',
52
- }),
52
+ })
53
53
  ).toMatchInlineSnapshot(`
54
54
  Array [
55
55
  Object {
@@ -81,7 +81,7 @@ describe('OpenAPI Schema', () => {
81
81
  expect(
82
82
  await validateDoc(source, {
83
83
  spec: 'error',
84
- }),
84
+ })
85
85
  ).toMatchInlineSnapshot(`
86
86
  Array [
87
87
  Object {
@@ -114,7 +114,7 @@ describe('OpenAPI Schema', () => {
114
114
  expect(
115
115
  await validateDoc(source, {
116
116
  spec: 'error',
117
- }),
117
+ })
118
118
  ).toMatchInlineSnapshot(`
119
119
  Array [
120
120
  Object {
@@ -146,7 +146,7 @@ describe('OpenAPI Schema', () => {
146
146
  expect(
147
147
  await validateDoc(source, {
148
148
  spec: 'error',
149
- }),
149
+ })
150
150
  ).toMatchInlineSnapshot(`Array []`);
151
151
  });
152
152
 
@@ -171,7 +171,7 @@ describe('OpenAPI Schema', () => {
171
171
  expect(
172
172
  await validateDoc(source, {
173
173
  spec: 'error',
174
- }),
174
+ })
175
175
  ).toMatchInlineSnapshot(`
176
176
  Array [
177
177
  Object {
@@ -208,7 +208,7 @@ describe('OpenAPI Schema', () => {
208
208
  expect(
209
209
  await validateDoc(source, {
210
210
  spec: 'error',
211
- }),
211
+ })
212
212
  ).toMatchInlineSnapshot(`Array []`);
213
213
  });
214
214
 
@@ -243,7 +243,7 @@ describe('OpenAPI Schema', () => {
243
243
  expect(
244
244
  await validateDoc(source, {
245
245
  spec: 'error',
246
- }),
246
+ })
247
247
  ).toMatchInlineSnapshot(`Array []`);
248
248
  });
249
249
 
@@ -277,7 +277,7 @@ describe('OpenAPI Schema', () => {
277
277
  expect(
278
278
  await validateDoc(source, {
279
279
  spec: 'error',
280
- }),
280
+ })
281
281
  ).toMatchInlineSnapshot(`
282
282
  Array [
283
283
  Object {
@@ -317,7 +317,7 @@ describe('OpenAPI Schema', () => {
317
317
  expect(
318
318
  await validateDoc(source, {
319
319
  'no-undefined-server-variable': 'error',
320
- }),
320
+ })
321
321
  ).toMatchInlineSnapshot(`
322
322
  Array [
323
323
  Object {
@@ -357,7 +357,7 @@ describe('OpenAPI Schema', () => {
357
357
  expect(
358
358
  await validateDoc(source, {
359
359
  spec: 'error',
360
- }),
360
+ })
361
361
  ).toMatchInlineSnapshot(`
362
362
  Array [
363
363
  Object {
@@ -403,7 +403,7 @@ describe('OpenAPI Schema', () => {
403
403
  expect(
404
404
  await validateDoc(source, {
405
405
  spec: 'error',
406
- }),
406
+ })
407
407
  ).toMatchInlineSnapshot(`
408
408
  Array [
409
409
  Object {
@@ -447,7 +447,7 @@ describe('OpenAPI Schema', () => {
447
447
  expect(
448
448
  await validateDoc(source, {
449
449
  spec: 'error',
450
- }),
450
+ })
451
451
  ).toMatchInlineSnapshot(`Array []`);
452
452
  });
453
453
 
@@ -469,7 +469,7 @@ describe('OpenAPI Schema', () => {
469
469
  expect(
470
470
  await validateDoc(source, {
471
471
  spec: 'error',
472
- }),
472
+ })
473
473
  ).toMatchInlineSnapshot(`Array []`);
474
474
  });
475
475
 
@@ -493,7 +493,7 @@ describe('OpenAPI Schema', () => {
493
493
  expect(
494
494
  await validateDoc(source, {
495
495
  spec: 'error',
496
- }),
496
+ })
497
497
  ).toMatchInlineSnapshot(`Array []`);
498
498
  });
499
499
  });
@@ -1,13 +1,13 @@
1
1
  import { outdent } from 'outdent';
2
2
  import { lintDocument } from '../../../../lint';
3
3
  import { parseYamlToDocument, replaceSourceWithRef } from '../../../../../__tests__/utils';
4
- import { LintConfig, defaultPlugin, resolvePlugins, resolvePreset } from '../../../../config';
4
+ import { StyleguideConfig, defaultPlugin, resolvePlugins, resolvePreset } from '../../../../config';
5
5
 
6
6
  import { BaseResolver } from '../../../../resolve';
7
7
 
8
8
  const plugins = resolvePlugins([defaultPlugin]);
9
9
  const pressets = resolvePreset('all', plugins);
10
- const allConfig = new LintConfig({ ...pressets, plugins });
10
+ const allConfig = new StyleguideConfig({ ...pressets, plugins });
11
11
  describe('Oas3 Structural visitor basic', () => {
12
12
  it('should report wrong types', async () => {
13
13
  const document = parseYamlToDocument(
@@ -35,7 +35,7 @@ describe('Oas3 Structural visitor basic', () => {
35
35
  license: invalid
36
36
  paths: {}
37
37
  `,
38
- 'foobar.yaml',
38
+ 'foobar.yaml'
39
39
  );
40
40
 
41
41
  const results = await lintDocument({
@@ -110,7 +110,7 @@ describe('Oas3 Structural visitor basic', () => {
110
110
  "source": "foobar.yaml",
111
111
  },
112
112
  ],
113
- "message": "Expected type \`string\` but got \`number\`.",
113
+ "message": "Expected type \`string\` but got \`integer\`.",
114
114
  "ruleId": "spec",
115
115
  "severity": "error",
116
116
  "suggest": Array [],
@@ -163,7 +163,7 @@ describe('Oas3 Structural visitor basic', () => {
163
163
  x-test: vendor
164
164
  paths: {}
165
165
  `,
166
- 'foobar.yaml',
166
+ 'foobar.yaml'
167
167
  );
168
168
 
169
169
  const results = await lintDocument({
@@ -232,7 +232,7 @@ describe('Oas3 Structural visitor basic', () => {
232
232
  contact:
233
233
  name: string
234
234
  `,
235
- 'foobar.yaml',
235
+ 'foobar.yaml'
236
236
  );
237
237
 
238
238
  const results = await lintDocument({
@@ -1,25 +1,25 @@
1
- import { LintConfig, RuleConfig, resolveLint } from '../../../../config';
1
+ import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config';
2
2
  import { parseYamlToDocument } from '../../../../../__tests__/utils';
3
3
  import { lintDocument } from '../../../../lint';
4
4
  import { BaseResolver } from '../../../../resolve';
5
5
 
6
6
  export async function validateDoc(
7
7
  source: string,
8
- rules: Record<string, RuleConfig> = { spec: 'error' },
8
+ rules: Record<string, RuleConfig> = { spec: 'error' }
9
9
  ) {
10
10
  const document = parseYamlToDocument(source, 'foobar.yaml');
11
11
 
12
12
  const results = await lintDocument({
13
13
  externalRefResolver: new BaseResolver(),
14
14
  document,
15
- config: new LintConfig(
16
- await resolveLint({
17
- lintConfig: {
15
+ config: new StyleguideConfig(
16
+ await resolveStyleguideConfig({
17
+ styleguideConfig: {
18
18
  plugins: [],
19
19
  extends: [],
20
20
  rules,
21
21
  },
22
- }),
22
+ })
23
23
  ),
24
24
  });
25
25
 
@@ -18,13 +18,13 @@ import { NoServerTrailingSlash } from './no-server-trailing-slash';
18
18
  import { InfoDescription } from '../common/info-description';
19
19
  import { TagDescription } from '../common/tag-description';
20
20
  import { InfoContact } from '../common/info-contact';
21
- import { InfoLicense } from '../common/info-license-url';
21
+ import { InfoLicense } from '../common/info-license';
22
+ import { InfoLicenseUrl } from '../common/info-license-url';
22
23
  import { OperationDescription } from '../common/operation-description';
23
24
  import { NoUnusedComponents } from './no-unused-components';
24
25
  import { PathNotIncludeQuery } from '../common/path-not-include-query';
25
26
  import { ParameterDescription } from '../common/parameter-description';
26
27
  import { OperationSingularTag } from '../common/operation-singular-tag';
27
- import { InfoLicenseUrl } from '../common/license-url';
28
28
  import { OperationSecurityDefined } from '../common/operation-security-defined';
29
29
  import { NoUnresolvedRefs } from '../no-unresolved-refs';
30
30
  import { BooleanParameterPrefixes } from './boolean-parameter-prefixes';
@@ -37,7 +37,7 @@ import { NoUndefinedServerVariable } from './no-undefined-server-variable';
37
37
  import { OperationOperationId } from '../common/operation-operationId';
38
38
  import { OperationSummary } from '../common/operation-summary';
39
39
  import { NoAmbiguousPaths } from '../common/no-ambiguous-paths';
40
- import { NoEmptyEnumServers } from './no-servers-empty-enum';
40
+ import { NoServerVariablesEmptyEnum } from './no-server-variables-empty-enum';
41
41
  import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths';
42
42
  import { RequestMimeType } from './request-mime-type';
43
43
  import { ResponseMimeType } from './response-mime-type';
@@ -57,7 +57,7 @@ export const rules = {
57
57
  'info-license-url': InfoLicenseUrl,
58
58
  'operation-2xx-response': Operation2xxResponse,
59
59
  'operation-4xx-response': Operation4xxResponse,
60
- 'assertions': Assertions,
60
+ assertions: Assertions,
61
61
  'operation-operationId-unique': OperationIdUnique,
62
62
  'operation-parameters-unique': OperationParametersUnique,
63
63
  'path-parameters-defined': PathParamsDefined,
@@ -89,7 +89,7 @@ export const rules = {
89
89
  'no-identical-paths': NoIdenticalPaths,
90
90
  'no-ambiguous-paths': NoAmbiguousPaths,
91
91
  'no-undefined-server-variable': NoUndefinedServerVariable,
92
- 'no-servers-empty-enum': NoEmptyEnumServers,
92
+ 'no-server-variables-empty-enum': NoServerVariablesEmptyEnum,
93
93
  'no-http-verbs-in-paths': NoHttpVerbsInPaths,
94
94
  'path-excludes-patterns': PathExcludesPatterns,
95
95
  'request-mime-type': RequestMimeType,
@@ -6,7 +6,7 @@ export const NoEmptyServers: Oas3Rule = () => {
6
6
  if (!root.hasOwnProperty('servers')) {
7
7
  report({
8
8
  message: 'Servers must be present.',
9
- location: location.child(['openapi']).key()
9
+ location: location.child(['openapi']).key(),
10
10
  });
11
11
  return;
12
12
  }
@@ -1,11 +1,11 @@
1
1
  import { Oas3Rule } from '../../visitors';
2
2
  import { Location, isRef } from '../../ref-utils';
3
3
  import { Oas3Example } from '../../typings/openapi';
4
- import { validateExample } from '../utils';
4
+ import { getAdditionalPropertiesOption, validateExample } from '../utils';
5
5
  import { UserContext } from '../../walk';
6
6
 
7
7
  export const ValidContentExamples: Oas3Rule = (opts) => {
8
- const disallowAdditionalProperties = opts.disallowAdditionalProperties ?? true;
8
+ const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false;
9
9
 
10
10
  return {
11
11
  MediaType: {
@@ -13,14 +13,22 @@ export const ValidContentExamples: Oas3Rule = (opts) => {
13
13
  const { location, resolve } = ctx;
14
14
  if (!mediaType.schema) return;
15
15
  if (mediaType.example) {
16
- resolveAndValidateExample(mediaType.example, location.child('example'));
16
+ resolveAndValidateExample(mediaType.example, location.child('example'));
17
17
  } else if (mediaType.examples) {
18
18
  for (const exampleName of Object.keys(mediaType.examples)) {
19
- resolveAndValidateExample(mediaType.examples[exampleName], location.child(['examples', exampleName, 'value']), true);
19
+ resolveAndValidateExample(
20
+ mediaType.examples[exampleName],
21
+ location.child(['examples', exampleName, 'value']),
22
+ true
23
+ );
20
24
  }
21
25
  }
22
26
 
23
- function resolveAndValidateExample(example: Oas3Example | any, location: Location, isMultiple?: boolean) {
27
+ function resolveAndValidateExample(
28
+ example: Oas3Example | any,
29
+ location: Location,
30
+ isMultiple?: boolean
31
+ ) {
24
32
  if (isRef(example)) {
25
33
  const resolved = resolve<Oas3Example>(example);
26
34
  if (!resolved.location) return;
@@ -32,7 +40,7 @@ export const ValidContentExamples: Oas3Rule = (opts) => {
32
40
  mediaType.schema!,
33
41
  location,
34
42
  ctx,
35
- disallowAdditionalProperties,
43
+ allowAdditionalProperties
36
44
  );
37
45
  }
38
46
  },
@@ -6,7 +6,7 @@ enum enumError {
6
6
  invalidDefaultValue = 'invalidDefaultValue',
7
7
  }
8
8
 
9
- export const NoEmptyEnumServers: Oas3Rule = () => {
9
+ export const NoServerVariablesEmptyEnum: Oas3Rule = () => {
10
10
  return {
11
11
  DefinitionRoot(root, { report, location }) {
12
12
  if (!root.servers || root.servers.length === 0) return;
@@ -25,16 +25,17 @@ export const NoEmptyEnumServers: Oas3Rule = () => {
25
25
  invalidVariables.push(...enumErrors);
26
26
  }
27
27
 
28
- for(const invalidVariable of invalidVariables) {
29
- if(invalidVariable === enumError.empty) {
28
+ for (const invalidVariable of invalidVariables) {
29
+ if (invalidVariable === enumError.empty) {
30
30
  report({
31
31
  message: 'Server variable with `enum` must be a non-empty array.',
32
32
  location: location.child(['servers']).key(),
33
33
  });
34
34
  }
35
- if(invalidVariable === enumError.invalidDefaultValue) {
35
+ if (invalidVariable === enumError.invalidDefaultValue) {
36
36
  report({
37
- message: 'Server variable define `enum` and `default`. `enum` must include default value',
37
+ message:
38
+ 'Server variable define `enum` and `default`. `enum` must include default value',
38
39
  location: location.child(['servers']).key(),
39
40
  });
40
41
  }
@@ -43,20 +44,18 @@ export const NoEmptyEnumServers: Oas3Rule = () => {
43
44
  };
44
45
  };
45
46
 
46
- function checkEnumVariables(server: Oas3Server): enumError[] | undefined{
47
- if (server.variables && Object.keys(server.variables).length === 0)
48
- return;
47
+ function checkEnumVariables(server: Oas3Server): enumError[] | undefined {
48
+ if (server.variables && Object.keys(server.variables).length === 0) return;
49
49
 
50
50
  const errors: enumError[] = [];
51
- for(var variable in server.variables) {
51
+ for (const variable in server.variables) {
52
52
  const serverVariable = server.variables[variable];
53
53
  if (!serverVariable.enum) continue;
54
54
 
55
55
  if (Array.isArray(serverVariable.enum) && serverVariable.enum?.length === 0)
56
56
  errors.push(enumError.empty);
57
57
 
58
- if (!serverVariable.default)
59
- continue;
58
+ if (!serverVariable.default) continue;
60
59
 
61
60
  const defaultValue = server.variables[variable].default;
62
61
  if (serverVariable.enum && !serverVariable.enum.includes(defaultValue))
@@ -2,7 +2,7 @@ import { Oas3Rule } from '../../visitors';
2
2
  import { Location } from '../../ref-utils';
3
3
 
4
4
  export const NoUnusedComponents: Oas3Rule = () => {
5
- let components = new Map<string, { used: boolean; location: Location; name: string }>();
5
+ const components = new Map<string, { used: boolean; location: Location; name: string }>();
6
6
 
7
7
  function registerComponent(location: Location, name: string): void {
8
8
  components.set(location.absolutePointer, {
@@ -1,12 +1,19 @@
1
1
  import { Oas3Rule } from '../../visitors';
2
2
  import { Location } from '../../ref-utils';
3
- import { Oas3Components } from '../../typings/openapi'
3
+ import { Oas3Components } from '../../typings/openapi';
4
4
  import { isEmptyObject } from '../../utils';
5
5
 
6
6
  export const RemoveUnusedComponents: Oas3Rule = () => {
7
- let components = new Map<string, { used: boolean; componentType?: keyof Oas3Components; name: string }>();
7
+ const components = new Map<
8
+ string,
9
+ { used: boolean; componentType?: keyof Oas3Components; name: string }
10
+ >();
8
11
 
9
- function registerComponent(location: Location, componentType: keyof Oas3Components, name: string): void {
12
+ function registerComponent(
13
+ location: Location,
14
+ componentType: keyof Oas3Components,
15
+ name: string
16
+ ): void {
10
17
  components.set(location.absolutePointer, {
11
18
  used: components.get(location.absolutePointer)?.used || false,
12
19
  componentType,
@@ -18,7 +25,9 @@ export const RemoveUnusedComponents: Oas3Rule = () => {
18
25
  ref: {
19
26
  leave(ref, { type, resolve, key }) {
20
27
  if (
21
- ['Schema', 'Header', 'Parameter', 'Response', 'Example', 'RequestBody'].includes(type.name)
28
+ ['Schema', 'Header', 'Parameter', 'Response', 'Example', 'RequestBody'].includes(
29
+ type.name
30
+ )
22
31
  ) {
23
32
  const resolvedRef = resolve(ref);
24
33
  if (!resolvedRef.location) return;
@@ -27,25 +36,27 @@ export const RemoveUnusedComponents: Oas3Rule = () => {
27
36
  name: key.toString(),
28
37
  });
29
38
  }
30
- }
39
+ },
31
40
  },
32
41
  DefinitionRoot: {
33
42
  leave(root, ctx) {
34
43
  const data = ctx.getVisitorData() as { removedCount: number };
35
44
  data.removedCount = 0;
36
45
 
37
- components.forEach(usageInfo => {
46
+ components.forEach((usageInfo) => {
38
47
  const { used, componentType, name } = usageInfo;
39
- if (!used && componentType) {
40
- let componentChild = root.components![componentType];
48
+ if (!used && componentType && root.components) {
49
+ const componentChild = root.components[componentType];
41
50
  delete componentChild![name];
42
51
  data.removedCount++;
43
52
  if (isEmptyObject(componentChild)) {
44
- delete root.components![componentType];
53
+ delete root.components[componentType];
45
54
  }
46
55
  }
47
56
  });
48
- if (isEmptyObject(root.components)) { delete root.components; }
57
+ if (isEmptyObject(root.components)) {
58
+ delete root.components;
59
+ }
49
60
  },
50
61
  },
51
62
  NamedSchemas: {