@redocly/openapi-core 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +13 -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 +23 -23
  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 +9 -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.d.ts +2 -0
  30. package/lib/config/utils.js +30 -15
  31. package/lib/decorators/common/filters/filter-helper.js +4 -4
  32. package/lib/decorators/common/filters/filter-in.js +2 -2
  33. package/lib/decorators/common/filters/filter-out.js +2 -2
  34. package/lib/decorators/common/info-description-override.js +1 -1
  35. package/lib/decorators/common/media-type-examples-override.js +3 -3
  36. package/lib/decorators/common/operation-description-override.js +1 -1
  37. package/lib/decorators/common/registry-dependencies.js +1 -1
  38. package/lib/decorators/common/remove-x-internal.js +4 -4
  39. package/lib/decorators/common/tag-description-override.js +1 -1
  40. package/lib/format/codeframes.d.ts +6 -6
  41. package/lib/format/format.d.ts +2 -2
  42. package/lib/format/format.js +12 -12
  43. package/lib/js-yaml/index.d.ts +2 -2
  44. package/lib/js-yaml/index.js +2 -2
  45. package/lib/lint.js +18 -18
  46. package/lib/oas-types.d.ts +12 -10
  47. package/lib/oas-types.js +2 -2
  48. package/lib/redocly/index.js +10 -10
  49. package/lib/redocly/registry-api.js +2 -2
  50. package/lib/resolve.d.ts +4 -4
  51. package/lib/resolve.js +18 -18
  52. package/lib/rules/ajv.js +1 -1
  53. package/lib/rules/async2/index.d.ts +2 -11
  54. package/lib/rules/common/assertions/asserts.d.ts +3 -3
  55. package/lib/rules/common/assertions/asserts.js +21 -21
  56. package/lib/rules/common/assertions/index.d.ts +4 -4
  57. package/lib/rules/common/assertions/index.js +3 -3
  58. package/lib/rules/common/assertions/utils.d.ts +4 -4
  59. package/lib/rules/common/assertions/utils.js +3 -3
  60. package/lib/rules/common/info-contact.js +1 -1
  61. package/lib/rules/common/info-license-url.js +1 -1
  62. package/lib/rules/common/info-license.js +1 -1
  63. package/lib/rules/common/no-enum-type-mismatch.js +3 -3
  64. package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
  65. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  66. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  67. package/lib/rules/common/operation-2xx-response.js +2 -2
  68. package/lib/rules/common/operation-4xx-response.js +2 -2
  69. package/lib/rules/common/operation-description.js +1 -1
  70. package/lib/rules/common/operation-operationId.js +1 -1
  71. package/lib/rules/common/operation-summary.js +1 -1
  72. package/lib/rules/common/path-segment-plural.js +1 -1
  73. package/lib/rules/common/response-contains-header.js +2 -2
  74. package/lib/rules/common/spec-strict-refs.js +1 -1
  75. package/lib/rules/common/spec.js +11 -11
  76. package/lib/rules/common/tag-description.js +1 -1
  77. package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
  78. package/lib/rules/oas2/index.d.ts +2 -46
  79. package/lib/rules/oas2/remove-unused-components.js +1 -1
  80. package/lib/rules/oas2/request-mime-type.js +2 -2
  81. package/lib/rules/oas2/response-contains-property.js +2 -2
  82. package/lib/rules/oas2/response-mime-type.js +2 -2
  83. package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
  84. package/lib/rules/oas3/index.d.ts +1 -1
  85. package/lib/rules/oas3/index.js +1 -1
  86. package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
  87. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
  88. package/lib/rules/oas3/remove-unused-components.js +2 -2
  89. package/lib/rules/oas3/request-mime-type.js +3 -3
  90. package/lib/rules/oas3/response-contains-property.js +2 -2
  91. package/lib/rules/oas3/response-mime-type.js +3 -3
  92. package/lib/rules/utils.js +3 -3
  93. package/lib/types/asyncapi.js +21 -21
  94. package/lib/types/index.d.ts +8 -8
  95. package/lib/types/oas2.js +14 -14
  96. package/lib/types/oas3.js +27 -27
  97. package/lib/types/oas3_1.js +6 -6
  98. package/lib/types/redocly-yaml.d.ts +11 -0
  99. package/lib/types/redocly-yaml.js +71 -53
  100. package/lib/types/theme-config.js +1 -1
  101. package/lib/typings/common.d.ts +2 -2
  102. package/lib/typings/openapi.d.ts +6 -6
  103. package/lib/typings/swagger.d.ts +3 -3
  104. package/lib/utils.d.ts +5 -5
  105. package/lib/utils.js +3 -3
  106. package/lib/visitors.d.ts +40 -40
  107. package/lib/walk.d.ts +14 -15
  108. package/lib/walk.js +11 -11
  109. package/package.json +2 -2
  110. package/src/__tests__/lint.test.ts +40 -40
  111. package/src/__tests__/normalizeVisitors.test.ts +23 -5
  112. package/src/__tests__/ref-utils.test.ts +7 -7
  113. package/src/__tests__/resolve-http.test.ts +10 -10
  114. package/src/__tests__/resolve.test.ts +39 -39
  115. package/src/__tests__/walk.test.ts +48 -48
  116. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
  117. package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
  118. package/src/config/__tests__/config-resolvers.test.ts +30 -1
  119. package/src/config/__tests__/config.test.ts +88 -88
  120. package/src/config/__tests__/load.test.ts +12 -8
  121. package/src/config/__tests__/utils.test.ts +18 -18
  122. package/src/config/all.ts +46 -9
  123. package/src/config/builtIn.ts +2 -0
  124. package/src/config/load.ts +4 -1
  125. package/src/config/minimal.ts +36 -4
  126. package/src/config/recommended-strict.ts +93 -0
  127. package/src/config/recommended.ts +36 -4
  128. package/src/config/types.ts +22 -8
  129. package/src/config/utils.ts +17 -0
  130. package/src/decorators/common/media-type-examples-override.ts +2 -2
  131. package/src/lint.ts +3 -3
  132. package/src/oas-types.ts +26 -3
  133. package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
  134. package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
  135. package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
  136. package/src/rules/async2/index.ts +2 -1
  137. package/src/rules/common/__tests__/info-license.test.ts +6 -6
  138. package/src/rules/common/__tests__/license-url.test.ts +6 -6
  139. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
  140. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
  141. package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
  142. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
  143. package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
  144. package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
  145. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
  146. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
  147. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
  148. package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
  149. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
  150. package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
  151. package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
  152. package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
  153. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
  154. package/src/rules/common/__tests__/security-defined.test.ts +21 -21
  155. package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
  156. package/src/rules/common/__tests__/spec.test.ts +102 -102
  157. package/src/rules/common/__tests__/tag-description.test.ts +6 -6
  158. package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
  159. package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
  160. package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
  161. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  162. package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
  163. package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
  164. package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
  165. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  166. package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
  167. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
  168. package/src/rules/oas2/index.ts +3 -1
  169. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  170. package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
  171. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
  172. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
  173. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
  174. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
  175. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
  176. package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
  177. package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
  178. package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
  179. package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
  180. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  181. package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
  182. package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
  183. package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
  184. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
  185. package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
  186. package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
  187. package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
  188. package/src/rules/oas3/index.ts +3 -3
  189. package/src/types/redocly-yaml.ts +75 -40
  190. package/src/visitors.ts +3 -3
  191. package/src/walk.ts +23 -10
  192. package/tsconfig.tsbuildinfo +1 -1
@@ -5,160 +5,160 @@ StyleguideConfig {
5
5
  "_usedRules": Set {},
6
6
  "_usedVersions": Set {},
7
7
  "configFile": undefined,
8
- "decorators": Object {
9
- "async2": Object {
10
- "oas2": Object {},
11
- "oas3_0": Object {},
12
- "oas3_1": Object {},
13
- },
14
- "oas2": Object {
15
- "oas2": Object {},
16
- "oas3_0": Object {},
17
- "oas3_1": Object {},
18
- },
19
- "oas3_0": Object {
20
- "oas2": Object {},
21
- "oas3_0": Object {},
22
- "oas3_1": Object {},
23
- },
24
- "oas3_1": Object {
25
- "oas2": Object {},
26
- "oas3_0": Object {},
27
- "oas3_1": Object {},
8
+ "decorators": {
9
+ "async2": {
10
+ "oas2": {},
11
+ "oas3_0": {},
12
+ "oas3_1": {},
13
+ },
14
+ "oas2": {
15
+ "oas2": {},
16
+ "oas3_0": {},
17
+ "oas3_1": {},
18
+ },
19
+ "oas3_0": {
20
+ "oas2": {},
21
+ "oas3_0": {},
22
+ "oas3_1": {},
23
+ },
24
+ "oas3_1": {
25
+ "oas2": {},
26
+ "oas3_0": {},
27
+ "oas3_1": {},
28
28
  },
29
29
  },
30
30
  "doNotResolveExamples": false,
31
- "extendPaths": Array [],
32
- "ignore": Object {
33
- "https://some-path.yaml": Object {
31
+ "extendPaths": [],
32
+ "ignore": {
33
+ "https://some-path.yaml": {
34
34
  "no-unused-components": Set {
35
35
  "#/components/schemas/Foo",
36
36
  },
37
37
  },
38
- "some-path/openapi.yaml": Object {
38
+ "some-path/openapi.yaml": {
39
39
  "no-unused-components": Set {
40
40
  "#/components/schemas/Foo",
41
41
  },
42
42
  },
43
43
  },
44
- "pluginPaths": Array [],
45
- "plugins": Array [],
46
- "preprocessors": Object {
47
- "async2": Object {
48
- "oas2": Object {},
49
- "oas3_0": Object {},
50
- "oas3_1": Object {},
51
- },
52
- "oas2": Object {
53
- "oas2": Object {},
54
- "oas3_0": Object {},
55
- "oas3_1": Object {},
56
- },
57
- "oas3_0": Object {
58
- "oas2": Object {},
59
- "oas3_0": Object {},
60
- "oas3_1": Object {},
61
- },
62
- "oas3_1": Object {
63
- "oas2": Object {},
64
- "oas3_0": Object {},
65
- "oas3_1": Object {},
44
+ "pluginPaths": [],
45
+ "plugins": [],
46
+ "preprocessors": {
47
+ "async2": {
48
+ "oas2": {},
49
+ "oas3_0": {},
50
+ "oas3_1": {},
51
+ },
52
+ "oas2": {
53
+ "oas2": {},
54
+ "oas3_0": {},
55
+ "oas3_1": {},
56
+ },
57
+ "oas3_0": {
58
+ "oas2": {},
59
+ "oas3_0": {},
60
+ "oas3_1": {},
61
+ },
62
+ "oas3_1": {
63
+ "oas2": {},
64
+ "oas3_0": {},
65
+ "oas3_1": {},
66
66
  },
67
67
  },
68
- "rawConfig": Object {
68
+ "rawConfig": {
69
69
  "_usedRules": Set {},
70
70
  "_usedVersions": Set {},
71
71
  "configFile": "redocly.yaml",
72
- "decorators": Object {
73
- "oas2": Object {},
74
- "oas3_0": Object {},
75
- "oas3_1": Object {},
72
+ "decorators": {
73
+ "oas2": {},
74
+ "oas3_0": {},
75
+ "oas3_1": {},
76
76
  },
77
77
  "doNotResolveExamples": false,
78
- "ignore": Object {},
79
- "plugins": Array [],
80
- "preprocessors": Object {
81
- "oas2": Object {},
82
- "oas3_0": Object {},
83
- "oas3_1": Object {},
78
+ "ignore": {},
79
+ "plugins": [],
80
+ "preprocessors": {
81
+ "oas2": {},
82
+ "oas3_0": {},
83
+ "oas3_1": {},
84
84
  },
85
- "rawConfig": Object {
86
- "plugins": Array [],
87
- "rules": Object {
85
+ "rawConfig": {
86
+ "plugins": [],
87
+ "rules": {
88
88
  "no-empty-servers": "error",
89
89
  "operation-summary": "error",
90
90
  },
91
91
  },
92
92
  "recommendedFallback": false,
93
- "rules": Object {
94
- "oas2": Object {
93
+ "rules": {
94
+ "oas2": {
95
95
  "no-empty-servers": "error",
96
96
  "operation-summary": "error",
97
97
  },
98
- "oas3_0": Object {
98
+ "oas3_0": {
99
99
  "no-empty-servers": "error",
100
100
  "operation-summary": "error",
101
101
  },
102
- "oas3_1": Object {
102
+ "oas3_1": {
103
103
  "no-empty-servers": "error",
104
104
  "operation-summary": "error",
105
105
  },
106
106
  },
107
107
  },
108
108
  "recommendedFallback": false,
109
- "rules": Object {
110
- "async2": Object {
111
- "oas2": Object {
109
+ "rules": {
110
+ "async2": {
111
+ "oas2": {
112
112
  "no-empty-servers": "error",
113
113
  "operation-summary": "error",
114
114
  },
115
- "oas3_0": Object {
115
+ "oas3_0": {
116
116
  "no-empty-servers": "error",
117
117
  "operation-summary": "error",
118
118
  },
119
- "oas3_1": Object {
119
+ "oas3_1": {
120
120
  "no-empty-servers": "error",
121
121
  "operation-summary": "error",
122
122
  },
123
123
  },
124
- "oas2": Object {
125
- "oas2": Object {
124
+ "oas2": {
125
+ "oas2": {
126
126
  "no-empty-servers": "error",
127
127
  "operation-summary": "error",
128
128
  },
129
- "oas3_0": Object {
129
+ "oas3_0": {
130
130
  "no-empty-servers": "error",
131
131
  "operation-summary": "error",
132
132
  },
133
- "oas3_1": Object {
133
+ "oas3_1": {
134
134
  "no-empty-servers": "error",
135
135
  "operation-summary": "error",
136
136
  },
137
137
  },
138
- "oas3_0": Object {
139
- "oas2": Object {
138
+ "oas3_0": {
139
+ "oas2": {
140
140
  "no-empty-servers": "error",
141
141
  "operation-summary": "error",
142
142
  },
143
- "oas3_0": Object {
143
+ "oas3_0": {
144
144
  "no-empty-servers": "error",
145
145
  "operation-summary": "error",
146
146
  },
147
- "oas3_1": Object {
147
+ "oas3_1": {
148
148
  "no-empty-servers": "error",
149
149
  "operation-summary": "error",
150
150
  },
151
151
  },
152
- "oas3_1": Object {
153
- "oas2": Object {
152
+ "oas3_1": {
153
+ "oas2": {
154
154
  "no-empty-servers": "error",
155
155
  "operation-summary": "error",
156
156
  },
157
- "oas3_0": Object {
157
+ "oas3_0": {
158
158
  "no-empty-servers": "error",
159
159
  "operation-summary": "error",
160
160
  },
161
- "oas3_1": Object {
161
+ "oas3_1": {
162
162
  "no-empty-servers": "error",
163
163
  "operation-summary": "error",
164
164
  },
@@ -1,9 +1,11 @@
1
1
  import { colorize } from '../../logger';
2
2
  import { Asserts, asserts } from '../../rules/common/assertions/asserts';
3
3
  import { resolveStyleguideConfig, resolveApis, resolveConfig } from '../config-resolvers';
4
+ import recommended from '../recommended';
5
+
4
6
  const path = require('path');
5
7
 
6
- import type { StyleguideRawConfig, RawConfig } from '../types';
8
+ import type { StyleguideRawConfig, RawConfig, PluginStyleguideConfig } from '../types';
7
9
 
8
10
  const configPath = path.join(__dirname, 'fixtures/resolve-config/redocly.yaml');
9
11
  const baseStyleguideConfig: StyleguideRawConfig = {
@@ -220,6 +222,33 @@ describe('resolveStyleguideConfig', () => {
220
222
  ]);
221
223
  expect(styleguide.pluginPaths!.map(removeAbsolutePath)).toEqual([]);
222
224
  });
225
+ it('should resolve `recommended-strict` ruleset correctly', async () => {
226
+ const expectedStrict = JSON.parse(
227
+ JSON.stringify(recommended)
228
+ ) as PluginStyleguideConfig<'built-in'>;
229
+ for (const section of Object.values(expectedStrict)) {
230
+ for (let ruleName in section as any) {
231
+ // @ts-ignore
232
+ if (section[ruleName] === 'warn') {
233
+ // @ts-ignore
234
+ section[ruleName] = 'error';
235
+ }
236
+ // @ts-ignore
237
+ if (section[ruleName]?.severity === 'warn') {
238
+ // @ts-ignore
239
+ section[ruleName].severity = 'error';
240
+ }
241
+ }
242
+ }
243
+ const recommendedStrictPreset = JSON.parse(
244
+ JSON.stringify(
245
+ await resolveStyleguideConfig({
246
+ styleguideConfig: { extends: ['recommended-strict'] },
247
+ })
248
+ )
249
+ );
250
+ expect(recommendedStrictPreset).toMatchObject(expectedStrict);
251
+ });
223
252
  });
224
253
 
225
254
  describe('resolveApis', () => {
@@ -69,95 +69,95 @@ describe('getMergedConfig', () => {
69
69
  it('should get styleguide defined in "apis" section', () => {
70
70
  expect(getMergedConfig(testConfig, 'test@v1')).toMatchInlineSnapshot(`
71
71
  Config {
72
- "apis": Object {
73
- "test@v1": Object {
72
+ "apis": {
73
+ "test@v1": {
74
74
  "root": "resources/pets.yaml",
75
- "styleguide": Object {
76
- "rules": Object {
75
+ "styleguide": {
76
+ "rules": {
77
77
  "operation-summary": "warn",
78
78
  },
79
79
  },
80
80
  },
81
81
  },
82
82
  "configFile": "redocly.yaml",
83
- "files": Array [],
83
+ "files": [],
84
84
  "organization": "redocly-test",
85
- "rawConfig": Object {
86
- "apis": Object {
87
- "test@v1": Object {
85
+ "rawConfig": {
86
+ "apis": {
87
+ "test@v1": {
88
88
  "root": "resources/pets.yaml",
89
- "styleguide": Object {
90
- "rules": Object {
89
+ "styleguide": {
90
+ "rules": {
91
91
  "operation-summary": "warn",
92
92
  },
93
93
  },
94
94
  },
95
95
  },
96
- "files": Array [],
96
+ "files": [],
97
97
  "organization": "redocly-test",
98
- "styleguide": Object {
99
- "extendPaths": Array [],
100
- "pluginPaths": Array [],
101
- "rules": Object {
98
+ "styleguide": {
99
+ "extendPaths": [],
100
+ "pluginPaths": [],
101
+ "rules": {
102
102
  "operation-summary": "warn",
103
103
  },
104
104
  },
105
105
  "telemetry": "on",
106
- "theme": Object {},
106
+ "theme": {},
107
107
  },
108
108
  "region": undefined,
109
- "resolve": Object {
110
- "http": Object {
109
+ "resolve": {
110
+ "http": {
111
111
  "customFetch": undefined,
112
- "headers": Array [],
112
+ "headers": [],
113
113
  },
114
114
  },
115
115
  "styleguide": StyleguideConfig {
116
116
  "_usedRules": Set {},
117
117
  "_usedVersions": Set {},
118
118
  "configFile": "redocly.yaml",
119
- "decorators": Object {
120
- "async2": Object {},
121
- "oas2": Object {},
122
- "oas3_0": Object {},
123
- "oas3_1": Object {},
119
+ "decorators": {
120
+ "async2": {},
121
+ "oas2": {},
122
+ "oas3_0": {},
123
+ "oas3_1": {},
124
124
  },
125
125
  "doNotResolveExamples": false,
126
- "extendPaths": Array [],
127
- "ignore": Object {},
128
- "pluginPaths": Array [],
129
- "plugins": Array [],
130
- "preprocessors": Object {
131
- "async2": Object {},
132
- "oas2": Object {},
133
- "oas3_0": Object {},
134
- "oas3_1": Object {},
126
+ "extendPaths": [],
127
+ "ignore": {},
128
+ "pluginPaths": [],
129
+ "plugins": [],
130
+ "preprocessors": {
131
+ "async2": {},
132
+ "oas2": {},
133
+ "oas3_0": {},
134
+ "oas3_1": {},
135
135
  },
136
- "rawConfig": Object {
137
- "extendPaths": Array [],
138
- "pluginPaths": Array [],
139
- "rules": Object {
136
+ "rawConfig": {
137
+ "extendPaths": [],
138
+ "pluginPaths": [],
139
+ "rules": {
140
140
  "operation-summary": "warn",
141
141
  },
142
142
  },
143
143
  "recommendedFallback": false,
144
- "rules": Object {
145
- "async2": Object {
144
+ "rules": {
145
+ "async2": {
146
146
  "operation-summary": "warn",
147
147
  },
148
- "oas2": Object {
148
+ "oas2": {
149
149
  "operation-summary": "warn",
150
150
  },
151
- "oas3_0": Object {
151
+ "oas3_0": {
152
152
  "operation-summary": "warn",
153
153
  },
154
- "oas3_1": Object {
154
+ "oas3_1": {
155
155
  "operation-summary": "warn",
156
156
  },
157
157
  },
158
158
  },
159
159
  "telemetry": "on",
160
- "theme": Object {},
160
+ "theme": {},
161
161
  }
162
162
  `);
163
163
  });
@@ -172,103 +172,103 @@ describe('getMergedConfig', () => {
172
172
  it('should handle wrong alias - return the same styleguide, empty features', () => {
173
173
  expect(getMergedConfig(testConfig, 'wrong-alias')).toMatchInlineSnapshot(`
174
174
  Config {
175
- "apis": Object {
176
- "test@v1": Object {
175
+ "apis": {
176
+ "test@v1": {
177
177
  "root": "resources/pets.yaml",
178
- "styleguide": Object {
179
- "rules": Object {
178
+ "styleguide": {
179
+ "rules": {
180
180
  "operation-summary": "warn",
181
181
  },
182
182
  },
183
183
  },
184
184
  },
185
185
  "configFile": "redocly.yaml",
186
- "files": Array [],
186
+ "files": [],
187
187
  "organization": "redocly-test",
188
- "rawConfig": Object {
189
- "apis": Object {
190
- "test@v1": Object {
188
+ "rawConfig": {
189
+ "apis": {
190
+ "test@v1": {
191
191
  "root": "resources/pets.yaml",
192
- "styleguide": Object {
193
- "rules": Object {
192
+ "styleguide": {
193
+ "rules": {
194
194
  "operation-summary": "warn",
195
195
  },
196
196
  },
197
197
  },
198
198
  },
199
- "files": Array [],
199
+ "files": [],
200
200
  "organization": "redocly-test",
201
- "styleguide": Object {
202
- "extendPaths": Array [],
203
- "pluginPaths": Array [],
204
- "plugins": Array [],
205
- "rules": Object {
201
+ "styleguide": {
202
+ "extendPaths": [],
203
+ "pluginPaths": [],
204
+ "plugins": [],
205
+ "rules": {
206
206
  "no-empty-servers": "error",
207
207
  "operation-summary": "error",
208
208
  },
209
209
  },
210
210
  "telemetry": "on",
211
- "theme": Object {},
211
+ "theme": {},
212
212
  },
213
213
  "region": undefined,
214
- "resolve": Object {
215
- "http": Object {
214
+ "resolve": {
215
+ "http": {
216
216
  "customFetch": undefined,
217
- "headers": Array [],
217
+ "headers": [],
218
218
  },
219
219
  },
220
220
  "styleguide": StyleguideConfig {
221
221
  "_usedRules": Set {},
222
222
  "_usedVersions": Set {},
223
223
  "configFile": "redocly.yaml",
224
- "decorators": Object {
225
- "async2": Object {},
226
- "oas2": Object {},
227
- "oas3_0": Object {},
228
- "oas3_1": Object {},
224
+ "decorators": {
225
+ "async2": {},
226
+ "oas2": {},
227
+ "oas3_0": {},
228
+ "oas3_1": {},
229
229
  },
230
230
  "doNotResolveExamples": false,
231
- "extendPaths": Array [],
232
- "ignore": Object {},
233
- "pluginPaths": Array [],
234
- "plugins": Array [],
235
- "preprocessors": Object {
236
- "async2": Object {},
237
- "oas2": Object {},
238
- "oas3_0": Object {},
239
- "oas3_1": Object {},
231
+ "extendPaths": [],
232
+ "ignore": {},
233
+ "pluginPaths": [],
234
+ "plugins": [],
235
+ "preprocessors": {
236
+ "async2": {},
237
+ "oas2": {},
238
+ "oas3_0": {},
239
+ "oas3_1": {},
240
240
  },
241
- "rawConfig": Object {
242
- "extendPaths": Array [],
243
- "pluginPaths": Array [],
244
- "plugins": Array [],
245
- "rules": Object {
241
+ "rawConfig": {
242
+ "extendPaths": [],
243
+ "pluginPaths": [],
244
+ "plugins": [],
245
+ "rules": {
246
246
  "no-empty-servers": "error",
247
247
  "operation-summary": "error",
248
248
  },
249
249
  },
250
250
  "recommendedFallback": false,
251
- "rules": Object {
252
- "async2": Object {
251
+ "rules": {
252
+ "async2": {
253
253
  "no-empty-servers": "error",
254
254
  "operation-summary": "error",
255
255
  },
256
- "oas2": Object {
256
+ "oas2": {
257
257
  "no-empty-servers": "error",
258
258
  "operation-summary": "error",
259
259
  },
260
- "oas3_0": Object {
260
+ "oas3_0": {
261
261
  "no-empty-servers": "error",
262
262
  "operation-summary": "error",
263
263
  },
264
- "oas3_1": Object {
264
+ "oas3_1": {
265
265
  "no-empty-servers": "error",
266
266
  "operation-summary": "error",
267
267
  },
268
268
  },
269
269
  },
270
270
  "telemetry": "on",
271
- "theme": Object {},
271
+ "theme": {},
272
272
  }
273
273
  `);
274
274
  });
@@ -172,17 +172,21 @@ function verifyExtendedConfig(
172
172
  const recommendedRules = defaultPlugin?.configs?.[extendsRuleSet];
173
173
  expect(recommendedRules).toBeDefined();
174
174
 
175
- verifyOasRules(config.styleguide.rules.oas2, overridesRules, recommendedRules?.rules || {});
176
175
  verifyOasRules(
177
- config.styleguide.rules.oas3_0,
176
+ config.styleguide.rules.oas2,
178
177
  overridesRules,
179
- Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_0Rules)
180
- );
181
- verifyOasRules(
182
- config.styleguide.rules.oas3_1,
183
- overridesRules,
184
- Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_1Rules)
178
+ { ...recommendedRules?.rules, ...recommendedRules?.oas2Rules } || {}
185
179
  );
180
+
181
+ verifyOasRules(config.styleguide.rules.oas3_0, overridesRules, {
182
+ ...recommendedRules?.rules,
183
+ ...recommendedRules?.oas3_0Rules,
184
+ });
185
+
186
+ verifyOasRules(config.styleguide.rules.oas3_1, overridesRules, {
187
+ ...recommendedRules?.rules,
188
+ ...recommendedRules?.oas3_1Rules,
189
+ });
186
190
  }
187
191
 
188
192
  function verifyOasRules(
@@ -78,25 +78,25 @@ describe('transformConfig', () => {
78
78
  makeTestRawConfig('styleguide', 'styleguide')
79
79
  );
80
80
  expect(transformedRawConfig).toMatchInlineSnapshot(`
81
- Object {
82
- "apis": Object {
83
- "test@v1": Object {
81
+ {
82
+ "apis": {
83
+ "test@v1": {
84
84
  "root": "root.yaml",
85
- "styleguide": Object {
86
- "rules": Object {
85
+ "styleguide": {
86
+ "rules": {
87
87
  "operation-2xx-response": "error",
88
88
  },
89
89
  },
90
90
  },
91
91
  },
92
- "styleguide": Object {
93
- "rules": Object {
92
+ "styleguide": {
93
+ "rules": {
94
94
  "operation-4xx-response": "warn",
95
95
  },
96
96
  },
97
- "theme": Object {
98
- "mockServer": Object {},
99
- "openapi": Object {},
97
+ "theme": {
98
+ "mockServer": {},
99
+ "openapi": {},
100
100
  },
101
101
  }
102
102
  `);
@@ -111,20 +111,20 @@ describe('transformConfig', () => {
111
111
  testRawConfig.apis = undefined;
112
112
  testRawConfig.apiDefinitions = { legacyApiDefinition: 'file.yaml' };
113
113
  expect(utils.transformConfig(testRawConfig)).toMatchInlineSnapshot(`
114
- Object {
115
- "apis": Object {
116
- "legacyApiDefinition": Object {
114
+ {
115
+ "apis": {
116
+ "legacyApiDefinition": {
117
117
  "root": "file.yaml",
118
118
  },
119
119
  },
120
- "styleguide": Object {
121
- "rules": Object {
120
+ "styleguide": {
121
+ "rules": {
122
122
  "operation-4xx-response": "warn",
123
123
  },
124
124
  },
125
- "theme": Object {
126
- "mockServer": Object {},
127
- "openapi": Object {},
125
+ "theme": {
126
+ "mockServer": {},
127
+ "openapi": {},
128
128
  },
129
129
  }
130
130
  `);