@redocly/openapi-core 1.18.0 → 1.19.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 (151) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/benchmark/benches/lint-with-many-rules.bench.js +2 -2
  3. package/lib/benchmark/benches/lint-with-nested-rule.bench.js +2 -2
  4. package/lib/benchmark/benches/lint-with-no-rules.bench.js +2 -2
  5. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +2 -2
  6. package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +2 -2
  7. package/lib/benchmark/benches/recommended-oas3.bench.js +2 -2
  8. package/lib/benchmark/benches/resolve-with-no-external.bench.js +2 -2
  9. package/lib/benchmark/utils.js +7 -4
  10. package/lib/bundle.d.ts +3 -3
  11. package/lib/bundle.js +128 -122
  12. package/lib/config/all.js +9 -0
  13. package/lib/config/builtIn.js +7 -1
  14. package/lib/config/config-resolvers.js +179 -138
  15. package/lib/config/config.d.ts +2 -2
  16. package/lib/config/config.js +53 -34
  17. package/lib/config/load.d.ts +1 -2
  18. package/lib/config/load.js +105 -117
  19. package/lib/config/minimal.js +9 -0
  20. package/lib/config/recommended-strict.js +9 -0
  21. package/lib/config/recommended.js +9 -0
  22. package/lib/config/rules.d.ts +3 -3
  23. package/lib/config/rules.js +1 -2
  24. package/lib/config/types.d.ts +9 -3
  25. package/lib/config/utils.js +70 -49
  26. package/lib/decorators/async3/index.d.ts +1 -0
  27. package/lib/decorators/async3/index.js +4 -0
  28. package/lib/decorators/common/filters/filter-helper.js +2 -3
  29. package/lib/decorators/common/filters/filter-in.js +1 -1
  30. package/lib/decorators/common/filters/filter-out.js +1 -1
  31. package/lib/decorators/common/info-override.js +1 -12
  32. package/lib/decorators/common/media-type-examples-override.js +8 -2
  33. package/lib/decorators/common/remove-x-internal.js +4 -5
  34. package/lib/decorators/oas2/remove-unused-components.js +1 -2
  35. package/lib/decorators/oas3/remove-unused-components.js +1 -2
  36. package/lib/env.d.ts +0 -1
  37. package/lib/env.js +1 -1
  38. package/lib/format/codeframes.js +10 -8
  39. package/lib/format/format.js +23 -15
  40. package/lib/index.d.ts +2 -1
  41. package/lib/index.js +6 -4
  42. package/lib/js-yaml/index.js +1 -1
  43. package/lib/lint.d.ts +2 -0
  44. package/lib/lint.js +92 -99
  45. package/lib/oas-types.d.ts +9 -5
  46. package/lib/oas-types.js +22 -12
  47. package/lib/redocly/domains.js +6 -6
  48. package/lib/redocly/index.js +60 -73
  49. package/lib/redocly/registry-api.js +64 -82
  50. package/lib/ref-utils.js +13 -13
  51. package/lib/resolve.js +186 -205
  52. package/lib/rules/ajv.js +10 -8
  53. package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
  54. package/lib/rules/async3/channels-kebab-case.js +19 -0
  55. package/lib/rules/async3/index.d.ts +3 -0
  56. package/lib/rules/async3/index.js +22 -0
  57. package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
  58. package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
  59. package/lib/rules/common/assertions/asserts.js +5 -5
  60. package/lib/rules/common/assertions/index.d.ts +5 -4
  61. package/lib/rules/common/assertions/utils.js +43 -28
  62. package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
  63. package/lib/rules/common/no-invalid-schema-examples.js +1 -2
  64. package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
  65. package/lib/rules/common/operation-tag-defined.js +1 -2
  66. package/lib/rules/common/path-http-verbs-order.js +1 -1
  67. package/lib/rules/common/path-segment-plural.js +2 -1
  68. package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
  69. package/lib/rules/common/response-contains-header.js +2 -2
  70. package/lib/rules/common/security-defined.js +3 -7
  71. package/lib/rules/common/spec.d.ts +2 -2
  72. package/lib/rules/common/spec.js +6 -7
  73. package/lib/rules/no-unresolved-refs.js +3 -4
  74. package/lib/rules/oas2/response-contains-property.js +1 -2
  75. package/lib/rules/oas3/array-parameter-serialization.js +1 -2
  76. package/lib/rules/oas3/component-name-unique.js +2 -4
  77. package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
  78. package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
  79. package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
  80. package/lib/rules/oas3/no-unused-components.js +1 -2
  81. package/lib/rules/oas3/response-contains-property.js +1 -2
  82. package/lib/rules/utils.js +14 -12
  83. package/lib/types/arazzo.d.ts +1299 -73
  84. package/lib/types/arazzo.js +41 -36
  85. package/lib/types/asyncapi2.d.ts +17 -0
  86. package/lib/types/{asyncapi.js → asyncapi2.js} +71 -93
  87. package/lib/types/asyncapi3.d.ts +2 -0
  88. package/lib/types/asyncapi3.js +347 -0
  89. package/lib/types/index.js +19 -10
  90. package/lib/types/json-schema-adapter.js +4 -18
  91. package/lib/types/oas2.js +6 -6
  92. package/lib/types/oas3.js +10 -10
  93. package/lib/types/oas3_1.js +15 -9
  94. package/lib/types/redocly-yaml.d.ts +3 -1
  95. package/lib/types/redocly-yaml.js +131 -35
  96. package/lib/typings/arazzo.d.ts +28 -1
  97. package/lib/typings/asyncapi3.d.ts +53 -0
  98. package/lib/typings/asyncapi3.js +2 -0
  99. package/lib/utils.d.ts +12 -7
  100. package/lib/utils.js +91 -77
  101. package/lib/visitors.d.ts +11 -0
  102. package/lib/visitors.js +21 -8
  103. package/lib/walk.js +30 -23
  104. package/package.json +3 -3
  105. package/src/__tests__/bundle.test.ts +142 -0
  106. package/src/__tests__/lint.test.ts +0 -50
  107. package/src/bundle.ts +19 -6
  108. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +22 -0
  109. package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
  110. package/src/config/__tests__/config.test.ts +11 -0
  111. package/src/config/all.ts +9 -0
  112. package/src/config/builtIn.ts +6 -0
  113. package/src/config/config-resolvers.ts +15 -2
  114. package/src/config/config.ts +24 -5
  115. package/src/config/load.ts +1 -2
  116. package/src/config/minimal.ts +9 -0
  117. package/src/config/recommended-strict.ts +9 -0
  118. package/src/config/recommended.ts +9 -0
  119. package/src/config/rules.ts +12 -4
  120. package/src/config/types.ts +15 -2
  121. package/src/config/utils.ts +15 -0
  122. package/src/decorators/async3/index.ts +1 -0
  123. package/src/decorators/common/remove-x-internal.ts +2 -2
  124. package/src/index.ts +2 -1
  125. package/src/lint.ts +26 -3
  126. package/src/oas-types.ts +31 -13
  127. package/src/rules/arazzo/index.ts +1 -1
  128. package/src/rules/async2/index.ts +5 -5
  129. package/src/rules/async3/__tests__/channels-kebab-case.test.ts +141 -0
  130. package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
  131. package/src/rules/async3/channels-kebab-case.ts +19 -0
  132. package/src/rules/async3/index.ts +23 -0
  133. package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
  134. package/src/rules/common/__tests__/spec.test.ts +47 -0
  135. package/src/rules/common/assertions/index.ts +13 -4
  136. package/src/rules/common/no-invalid-schema-examples.ts +3 -2
  137. package/src/rules/common/path-segment-plural.ts +3 -2
  138. package/src/rules/common/spec.ts +2 -2
  139. package/src/rules/oas2/index.ts +4 -4
  140. package/src/rules/oas3/index.ts +39 -37
  141. package/src/types/arazzo.ts +28 -23
  142. package/src/types/{asyncapi.ts → asyncapi2.ts} +58 -76
  143. package/src/types/asyncapi3.ts +381 -0
  144. package/src/types/oas3_1.ts +3 -2
  145. package/src/types/redocly-yaml.ts +14 -0
  146. package/src/typings/arazzo.ts +41 -1
  147. package/src/typings/asyncapi3.ts +61 -0
  148. package/src/utils.ts +46 -11
  149. package/src/visitors.ts +18 -0
  150. package/tsconfig.tsbuildinfo +1 -1
  151. package/lib/types/asyncapi.d.ts +0 -2
@@ -1,26 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
2
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.resolvePreset = exports.resolveStyleguideConfig = exports.resolveApis = exports.resolvePlugins = exports.resolveConfig = exports.resolveConfigFileAndRefs = void 0;
3
+ exports.resolveConfigFileAndRefs = resolveConfigFileAndRefs;
4
+ exports.resolveConfig = resolveConfig;
5
+ exports.resolvePlugins = resolvePlugins;
6
+ exports.resolveApis = resolveApis;
7
+ exports.resolveStyleguideConfig = resolveStyleguideConfig;
8
+ exports.resolvePreset = resolvePreset;
24
9
  const path = require("path");
25
10
  const ref_utils_1 = require("../ref-utils");
26
11
  const utils_1 = require("../utils");
@@ -34,47 +19,43 @@ const logger_1 = require("../logger");
34
19
  const asserts_1 = require("../rules/common/assertions/asserts");
35
20
  const types_1 = require("../types");
36
21
  const redocly_yaml_1 = require("../types/redocly-yaml");
37
- function resolveConfigFileAndRefs({ configPath, externalRefResolver = new resolve_1.BaseResolver(), base = null, }) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- if (!configPath) {
40
- throw new Error('Reference to a config is required.\n');
41
- }
42
- const document = yield externalRefResolver.resolveDocument(base, configPath, true);
43
- if (document instanceof Error) {
44
- throw document;
45
- }
46
- const types = (0, types_1.normalizeTypes)(redocly_yaml_1.ConfigTypes);
47
- const resolvedRefMap = yield (0, resolve_1.resolveDocument)({
48
- rootDocument: document,
49
- rootType: types.ConfigRoot,
50
- externalRefResolver,
51
- });
52
- return { document, resolvedRefMap };
22
+ async function resolveConfigFileAndRefs({ configPath, externalRefResolver = new resolve_1.BaseResolver(), base = null, }) {
23
+ if (!configPath) {
24
+ throw new Error('Reference to a config is required.\n');
25
+ }
26
+ const document = await externalRefResolver.resolveDocument(base, configPath, true);
27
+ if (document instanceof Error) {
28
+ throw document;
29
+ }
30
+ const types = (0, types_1.normalizeTypes)(redocly_yaml_1.ConfigTypes);
31
+ const resolvedRefMap = await (0, resolve_1.resolveDocument)({
32
+ rootDocument: document,
33
+ rootType: types.ConfigRoot,
34
+ externalRefResolver,
53
35
  });
36
+ return { document, resolvedRefMap };
54
37
  }
55
- exports.resolveConfigFileAndRefs = resolveConfigFileAndRefs;
56
- function resolveConfig({ rawConfig, configPath, externalRefResolver, }) {
57
- var _a, _b;
58
- return __awaiter(this, void 0, void 0, function* () {
59
- if ((_b = (_a = rawConfig.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_3.isNotString)) {
60
- throw new Error(`Error configuration format not detected in extends value must contain strings`);
61
- }
62
- const resolver = externalRefResolver !== null && externalRefResolver !== void 0 ? externalRefResolver : new resolve_1.BaseResolver((0, utils_2.getResolveConfig)(rawConfig.resolve));
63
- const apis = yield resolveApis({
64
- rawConfig,
65
- configPath,
66
- resolver,
67
- });
68
- const styleguide = yield resolveStyleguideConfig({
69
- styleguideConfig: rawConfig.styleguide,
70
- configPath,
71
- resolver,
72
- });
73
- return new config_1.Config(Object.assign(Object.assign({}, rawConfig), { apis,
74
- styleguide }), configPath);
38
+ async function resolveConfig({ rawConfig, configPath, externalRefResolver, }) {
39
+ if (rawConfig.styleguide?.extends?.some(utils_3.isNotString)) {
40
+ throw new Error(`Error configuration format not detected in extends value must contain strings`);
41
+ }
42
+ const resolver = externalRefResolver ?? new resolve_1.BaseResolver((0, utils_2.getResolveConfig)(rawConfig.resolve));
43
+ const apis = await resolveApis({
44
+ rawConfig,
45
+ configPath,
46
+ resolver,
47
+ });
48
+ const styleguide = await resolveStyleguideConfig({
49
+ styleguideConfig: rawConfig.styleguide,
50
+ configPath,
51
+ resolver,
75
52
  });
53
+ return new config_1.Config({
54
+ ...rawConfig,
55
+ apis,
56
+ styleguide,
57
+ }, configPath);
76
58
  }
77
- exports.resolveConfig = resolveConfig;
78
59
  function resolvePlugins(plugins, configPath = '') {
79
60
  if (!plugins)
80
61
  return [];
@@ -124,10 +105,14 @@ function resolvePlugins(plugins, configPath = '') {
124
105
  throw new Error(logger_1.colorize.red(`Plugin "id" must be unique. Plugin ${logger_1.colorize.blue(p.toString())} uses id "${logger_1.colorize.blue(id)}" already seen in ${logger_1.colorize.blue(pluginPath)}`));
125
106
  }
126
107
  seenPluginIds.set(id, p.toString());
127
- const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
108
+ const plugin = {
109
+ id,
110
+ ...(pluginModule.configs ? { configs: pluginModule.configs } : {}),
111
+ ...(pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}),
112
+ };
128
113
  if (pluginModule.rules) {
129
114
  if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
130
- throw new Error(`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, or \`arazzo\` rules "${p}.`);
115
+ throw new Error(`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\` or \`arazzo\` rules "${p}.`);
131
116
  }
132
117
  plugin.rules = {};
133
118
  if (pluginModule.rules.oas3) {
@@ -139,6 +124,9 @@ function resolvePlugins(plugins, configPath = '') {
139
124
  if (pluginModule.rules.async2) {
140
125
  plugin.rules.async2 = (0, utils_2.prefixRules)(pluginModule.rules.async2, id);
141
126
  }
127
+ if (pluginModule.rules.async3) {
128
+ plugin.rules.async3 = (0, utils_2.prefixRules)(pluginModule.rules.async3, id);
129
+ }
142
130
  if (pluginModule.rules.arazzo) {
143
131
  plugin.rules.arazzo = (0, utils_2.prefixRules)(pluginModule.rules.arazzo, id);
144
132
  }
@@ -147,6 +135,7 @@ function resolvePlugins(plugins, configPath = '') {
147
135
  if (!pluginModule.preprocessors.oas3 &&
148
136
  !pluginModule.preprocessors.oas2 &&
149
137
  !pluginModule.preprocessors.async2 &&
138
+ !pluginModule.preprocessors.async3 &&
150
139
  !pluginModule.preprocessors.arazzo) {
151
140
  throw new Error(`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`);
152
141
  }
@@ -160,6 +149,9 @@ function resolvePlugins(plugins, configPath = '') {
160
149
  if (pluginModule.preprocessors.async2) {
161
150
  plugin.preprocessors.async2 = (0, utils_2.prefixRules)(pluginModule.preprocessors.async2, id);
162
151
  }
152
+ if (pluginModule.preprocessors.async3) {
153
+ plugin.preprocessors.async3 = (0, utils_2.prefixRules)(pluginModule.preprocessors.async3, id);
154
+ }
163
155
  if (pluginModule.preprocessors.arazzo) {
164
156
  plugin.preprocessors.arazzo = (0, utils_2.prefixRules)(pluginModule.preprocessors.arazzo, id);
165
157
  }
@@ -168,8 +160,9 @@ function resolvePlugins(plugins, configPath = '') {
168
160
  if (!pluginModule.decorators.oas3 &&
169
161
  !pluginModule.decorators.oas2 &&
170
162
  !pluginModule.decorators.async2 &&
163
+ !pluginModule.decorators.async3 &&
171
164
  !pluginModule.decorators.arazzo) {
172
- throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\` or \`async2\` decorators "${p}.`);
165
+ throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\` or \`async3\` decorators "${p}.`);
173
166
  }
174
167
  plugin.decorators = {};
175
168
  if (pluginModule.decorators.oas3) {
@@ -181,6 +174,9 @@ function resolvePlugins(plugins, configPath = '') {
181
174
  if (pluginModule.decorators.async2) {
182
175
  plugin.decorators.async2 = (0, utils_2.prefixRules)(pluginModule.decorators.async2, id);
183
176
  }
177
+ if (pluginModule.decorators.async3) {
178
+ plugin.decorators.async3 = (0, utils_2.prefixRules)(pluginModule.decorators.async3, id);
179
+ }
184
180
  if (pluginModule.decorators.arazzo) {
185
181
  plugin.decorators.arazzo = (0, utils_2.prefixRules)(pluginModule.decorators.arazzo, id);
186
182
  }
@@ -192,77 +188,82 @@ function resolvePlugins(plugins, configPath = '') {
192
188
  })
193
189
  .filter(utils_3.isDefined);
194
190
  }
195
- exports.resolvePlugins = resolvePlugins;
196
- function resolveApis({ rawConfig, configPath = '', resolver, }) {
197
- var _a, _b;
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const { apis = {}, styleguide: styleguideConfig = {} } = rawConfig;
200
- const resolvedApis = {};
201
- for (const [apiName, apiContent] of Object.entries(apis || {})) {
202
- if ((_b = (_a = apiContent.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_3.isNotString)) {
203
- throw new Error(`Error configuration format not detected in extends value must contain strings`);
204
- }
205
- const rawStyleguideConfig = getMergedRawStyleguideConfig(styleguideConfig, apiContent.styleguide);
206
- const resolvedApiConfig = yield resolveStyleguideConfig({
207
- styleguideConfig: rawStyleguideConfig,
208
- configPath,
209
- resolver,
210
- });
211
- resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), { styleguide: resolvedApiConfig });
191
+ async function resolveApis({ rawConfig, configPath = '', resolver, }) {
192
+ const { apis = {}, styleguide: styleguideConfig = {} } = rawConfig;
193
+ const resolvedApis = {};
194
+ for (const [apiName, apiContent] of Object.entries(apis || {})) {
195
+ if (apiContent.styleguide?.extends?.some(utils_3.isNotString)) {
196
+ throw new Error(`Error configuration format not detected in extends value must contain strings`);
212
197
  }
213
- return resolvedApis;
214
- });
198
+ const rawStyleguideConfig = getMergedRawStyleguideConfig(styleguideConfig, apiContent.styleguide);
199
+ const resolvedApiConfig = await resolveStyleguideConfig({
200
+ styleguideConfig: rawStyleguideConfig,
201
+ configPath,
202
+ resolver,
203
+ });
204
+ resolvedApis[apiName] = { ...apiContent, styleguide: resolvedApiConfig };
205
+ }
206
+ return resolvedApis;
215
207
  }
216
- exports.resolveApis = resolveApis;
217
- function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
218
- var _a, _b, _c;
219
- return __awaiter(this, void 0, void 0, function* () {
220
- if (parentConfigPaths.includes(configPath)) {
221
- throw new Error(`Circular dependency in config file: "${configPath}"`);
208
+ async function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
209
+ if (parentConfigPaths.includes(configPath)) {
210
+ throw new Error(`Circular dependency in config file: "${configPath}"`);
211
+ }
212
+ const plugins = (0, utils_2.getUniquePlugins)(resolvePlugins([...(styleguideConfig?.plugins || []), builtIn_1.defaultPlugin], configPath));
213
+ const pluginPaths = styleguideConfig?.plugins
214
+ ?.filter(utils_3.isString)
215
+ .map((p) => path.resolve(path.dirname(configPath), p));
216
+ const resolvedConfigPath = (0, ref_utils_1.isAbsoluteUrl)(configPath)
217
+ ? configPath
218
+ : configPath && path.resolve(configPath);
219
+ const extendConfigs = await Promise.all(styleguideConfig?.extends?.map(async (presetItem) => {
220
+ if (!(0, ref_utils_1.isAbsoluteUrl)(presetItem) && !path.extname(presetItem)) {
221
+ return resolvePreset(presetItem, plugins);
222
222
  }
223
- const plugins = (0, utils_2.getUniquePlugins)(resolvePlugins([...((styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) || []), builtIn_1.defaultPlugin], configPath));
224
- const pluginPaths = (_a = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(utils_3.isString).map((p) => path.resolve(path.dirname(configPath), p));
225
- const resolvedConfigPath = (0, ref_utils_1.isAbsoluteUrl)(configPath)
226
- ? configPath
227
- : configPath && path.resolve(configPath);
228
- const extendConfigs = yield Promise.all(((_b = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.extends) === null || _b === void 0 ? void 0 : _b.map((presetItem) => __awaiter(this, void 0, void 0, function* () {
229
- if (!(0, ref_utils_1.isAbsoluteUrl)(presetItem) && !path.extname(presetItem)) {
230
- return resolvePreset(presetItem, plugins);
231
- }
232
- const pathItem = (0, ref_utils_1.isAbsoluteUrl)(presetItem)
233
- ? presetItem
234
- : (0, ref_utils_1.isAbsoluteUrl)(configPath)
235
- ? new URL(presetItem, configPath).href
236
- : path.resolve(path.dirname(configPath), presetItem);
237
- const extendedStyleguideConfig = yield loadExtendStyleguideConfig(pathItem, resolver);
238
- return yield resolveAndMergeNestedStyleguideConfig({
239
- styleguideConfig: extendedStyleguideConfig,
240
- configPath: pathItem,
241
- resolver: resolver,
242
- }, [...parentConfigPaths, resolvedConfigPath], extendPaths);
243
- }))) || []);
244
- const _d = (0, utils_2.mergeExtends)([
245
- ...extendConfigs,
246
- Object.assign(Object.assign({}, styleguideConfig), { plugins, extends: undefined, extendPaths: [...parentConfigPaths, resolvedConfigPath], pluginPaths }),
247
- ]), { plugins: mergedPlugins = [] } = _d, styleguide = __rest(_d, ["plugins"]);
248
- return Object.assign(Object.assign({}, styleguide), { extendPaths: (_c = styleguide.extendPaths) === null || _c === void 0 ? void 0 : _c.filter((path) => path && !(0, ref_utils_1.isAbsoluteUrl)(path)), plugins: (0, utils_2.getUniquePlugins)(mergedPlugins), recommendedFallback: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.recommendedFallback, doNotResolveExamples: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.doNotResolveExamples });
249
- });
223
+ const pathItem = (0, ref_utils_1.isAbsoluteUrl)(presetItem)
224
+ ? presetItem
225
+ : (0, ref_utils_1.isAbsoluteUrl)(configPath)
226
+ ? new URL(presetItem, configPath).href
227
+ : path.resolve(path.dirname(configPath), presetItem);
228
+ const extendedStyleguideConfig = await loadExtendStyleguideConfig(pathItem, resolver);
229
+ return await resolveAndMergeNestedStyleguideConfig({
230
+ styleguideConfig: extendedStyleguideConfig,
231
+ configPath: pathItem,
232
+ resolver: resolver,
233
+ }, [...parentConfigPaths, resolvedConfigPath], extendPaths);
234
+ }) || []);
235
+ const { plugins: mergedPlugins = [], ...styleguide } = (0, utils_2.mergeExtends)([
236
+ ...extendConfigs,
237
+ {
238
+ ...styleguideConfig,
239
+ plugins,
240
+ extends: undefined,
241
+ extendPaths: [...parentConfigPaths, resolvedConfigPath],
242
+ pluginPaths,
243
+ },
244
+ ]);
245
+ return {
246
+ ...styleguide,
247
+ extendPaths: styleguide.extendPaths?.filter((path) => path && !(0, ref_utils_1.isAbsoluteUrl)(path)),
248
+ plugins: (0, utils_2.getUniquePlugins)(mergedPlugins),
249
+ recommendedFallback: styleguideConfig?.recommendedFallback,
250
+ doNotResolveExamples: styleguideConfig?.doNotResolveExamples,
251
+ };
250
252
  }
251
- function resolveStyleguideConfig(opts, parentConfigPaths = [], extendPaths = []) {
252
- return __awaiter(this, void 0, void 0, function* () {
253
- const resolvedStyleguideConfig = yield resolveAndMergeNestedStyleguideConfig(opts, parentConfigPaths, extendPaths);
254
- return Object.assign(Object.assign({}, resolvedStyleguideConfig), { rules: resolvedStyleguideConfig.rules && groupStyleguideAssertionRules(resolvedStyleguideConfig) });
255
- });
253
+ async function resolveStyleguideConfig(opts, parentConfigPaths = [], extendPaths = []) {
254
+ const resolvedStyleguideConfig = await resolveAndMergeNestedStyleguideConfig(opts, parentConfigPaths, extendPaths);
255
+ return {
256
+ ...resolvedStyleguideConfig,
257
+ rules: resolvedStyleguideConfig.rules && groupStyleguideAssertionRules(resolvedStyleguideConfig),
258
+ };
256
259
  }
257
- exports.resolveStyleguideConfig = resolveStyleguideConfig;
258
260
  function resolvePreset(presetName, plugins) {
259
- var _a;
260
261
  const { pluginId, configName } = (0, utils_2.parsePresetName)(presetName);
261
262
  const plugin = plugins.find((p) => p.id === pluginId);
262
263
  if (!plugin) {
263
264
  throw new Error(`Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} is not included.`);
264
265
  }
265
- const preset = (_a = plugin.configs) === null || _a === void 0 ? void 0 : _a[configName];
266
+ const preset = plugin.configs?.[configName];
266
267
  if (!preset) {
267
268
  throw new Error(pluginId
268
269
  ? `Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.`
@@ -270,26 +271,63 @@ function resolvePreset(presetName, plugins) {
270
271
  }
271
272
  return preset;
272
273
  }
273
- exports.resolvePreset = resolvePreset;
274
- function loadExtendStyleguideConfig(filePath, resolver) {
275
- return __awaiter(this, void 0, void 0, function* () {
276
- try {
277
- const { parsed } = (yield resolver.resolveDocument(null, filePath));
278
- const rawConfig = (0, utils_2.transformConfig)(parsed);
279
- if (!rawConfig.styleguide) {
280
- throw new Error(`Styleguide configuration format not detected: "${filePath}"`);
281
- }
282
- return rawConfig.styleguide;
274
+ async function loadExtendStyleguideConfig(filePath, resolver) {
275
+ try {
276
+ const { parsed } = (await resolver.resolveDocument(null, filePath));
277
+ const rawConfig = (0, utils_2.transformConfig)(parsed);
278
+ if (!rawConfig.styleguide) {
279
+ throw new Error(`Styleguide configuration format not detected: "${filePath}"`);
283
280
  }
284
- catch (error) {
285
- throw new Error(`Failed to load "${filePath}": ${error.message}`);
286
- }
287
- });
281
+ return rawConfig.styleguide;
282
+ }
283
+ catch (error) {
284
+ throw new Error(`Failed to load "${filePath}": ${error.message}`);
285
+ }
288
286
  }
289
287
  function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig) {
290
- const resultLint = Object.assign(Object.assign(Object.assign({}, rootStyleguideConfig), (0, utils_1.pickDefined)(apiStyleguideConfig)), { rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.rules), oas2Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Rules), arazzoRules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.arazzoRules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.arazzoRules), preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.decorators), oas2Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Decorators), recommendedFallback: (apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.extends)
288
+ const resultLint = {
289
+ ...rootStyleguideConfig,
290
+ ...(0, utils_1.pickDefined)(apiStyleguideConfig),
291
+ rules: { ...rootStyleguideConfig?.rules, ...apiStyleguideConfig?.rules },
292
+ oas2Rules: { ...rootStyleguideConfig?.oas2Rules, ...apiStyleguideConfig?.oas2Rules },
293
+ oas3_0Rules: { ...rootStyleguideConfig?.oas3_0Rules, ...apiStyleguideConfig?.oas3_0Rules },
294
+ oas3_1Rules: { ...rootStyleguideConfig?.oas3_1Rules, ...apiStyleguideConfig?.oas3_1Rules },
295
+ async2Rules: { ...rootStyleguideConfig?.async2Rules, ...apiStyleguideConfig?.async2Rules },
296
+ async3Rules: { ...rootStyleguideConfig?.async3Rules, ...apiStyleguideConfig?.async3Rules },
297
+ arazzoRules: { ...rootStyleguideConfig?.arazzoRules, ...apiStyleguideConfig?.arazzoRules },
298
+ preprocessors: {
299
+ ...rootStyleguideConfig?.preprocessors,
300
+ ...apiStyleguideConfig?.preprocessors,
301
+ },
302
+ oas2Preprocessors: {
303
+ ...rootStyleguideConfig?.oas2Preprocessors,
304
+ ...apiStyleguideConfig?.oas2Preprocessors,
305
+ },
306
+ oas3_0Preprocessors: {
307
+ ...rootStyleguideConfig?.oas3_0Preprocessors,
308
+ ...apiStyleguideConfig?.oas3_0Preprocessors,
309
+ },
310
+ oas3_1Preprocessors: {
311
+ ...rootStyleguideConfig?.oas3_1Preprocessors,
312
+ ...apiStyleguideConfig?.oas3_1Preprocessors,
313
+ },
314
+ decorators: { ...rootStyleguideConfig?.decorators, ...apiStyleguideConfig?.decorators },
315
+ oas2Decorators: {
316
+ ...rootStyleguideConfig?.oas2Decorators,
317
+ ...apiStyleguideConfig?.oas2Decorators,
318
+ },
319
+ oas3_0Decorators: {
320
+ ...rootStyleguideConfig?.oas3_0Decorators,
321
+ ...apiStyleguideConfig?.oas3_0Decorators,
322
+ },
323
+ oas3_1Decorators: {
324
+ ...rootStyleguideConfig?.oas3_1Decorators,
325
+ ...apiStyleguideConfig?.oas3_1Decorators,
326
+ },
327
+ recommendedFallback: apiStyleguideConfig?.extends
291
328
  ? false
292
- : rootStyleguideConfig.recommendedFallback });
329
+ : rootStyleguideConfig.recommendedFallback,
330
+ };
293
331
  return resultLint;
294
332
  }
295
333
  function groupStyleguideAssertionRules({ rules, plugins, }) {
@@ -313,7 +351,10 @@ function groupStyleguideAssertionRules({ rules, plugins, }) {
313
351
  registerCustomAssertions(plugins, context);
314
352
  }
315
353
  }
316
- assertions.push(Object.assign(Object.assign({}, assertion), { assertionId: ruleKey }));
354
+ assertions.push({
355
+ ...assertion,
356
+ assertionId: ruleKey,
357
+ });
317
358
  }
318
359
  else {
319
360
  // If it's not an assertion, keep it as is
@@ -1,5 +1,5 @@
1
1
  import { NormalizedProblem } from '../walk';
2
- import { SpecVersion, SpecMajorVersion, Oas2RuleSet, Oas3RuleSet, Async2RuleSet, ArazzoRuleSet } from '../oas-types';
2
+ import { SpecVersion, SpecMajorVersion, Oas2RuleSet, Oas3RuleSet, Async3RuleSet, ArazzoRuleSet } from '../oas-types';
3
3
  import type { NodeType } from '../types';
4
4
  import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types';
5
5
  export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
@@ -31,7 +31,7 @@ export declare class StyleguideConfig {
31
31
  preprocessors: string[];
32
32
  decorators: string[];
33
33
  };
34
- getRulesForOasVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async2RuleSet[] | ArazzoRuleSet[];
34
+ getRulesForOasVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async3RuleSet[] | ArazzoRuleSet[];
35
35
  skipRules(rules?: string[]): void;
36
36
  skipPreprocessors(preprocessors?: string[]): void;
37
37
  skipDecorators(decorators?: string[]): void;
@@ -33,25 +33,28 @@ class StyleguideConfig {
33
33
  this.doNotResolveExamples = !!rawConfig.doNotResolveExamples;
34
34
  this.recommendedFallback = rawConfig.recommendedFallback || false;
35
35
  this.rules = {
36
- [oas_types_1.SpecVersion.OAS2]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas2Rules),
37
- [oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_0Rules),
38
- [oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_1Rules),
39
- [oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.async2Rules),
40
- [oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoRules),
36
+ [oas_types_1.SpecVersion.OAS2]: { ...rawConfig.rules, ...rawConfig.oas2Rules },
37
+ [oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules },
38
+ [oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules },
39
+ [oas_types_1.SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
40
+ [oas_types_1.SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules },
41
+ [oas_types_1.SpecVersion.Arazzo]: { ...rawConfig.arazzoRules },
41
42
  };
42
43
  this.preprocessors = {
43
- [oas_types_1.SpecVersion.OAS2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas2Preprocessors),
44
- [oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_0Preprocessors),
45
- [oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_1Preprocessors),
46
- [oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.async2Preprocessors),
47
- [oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoPreprocessors),
44
+ [oas_types_1.SpecVersion.OAS2]: { ...rawConfig.preprocessors, ...rawConfig.oas2Preprocessors },
45
+ [oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.preprocessors, ...rawConfig.oas3_0Preprocessors },
46
+ [oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors },
47
+ [oas_types_1.SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
48
+ [oas_types_1.SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors },
49
+ [oas_types_1.SpecVersion.Arazzo]: { ...rawConfig.arazzoPreprocessors },
48
50
  };
49
51
  this.decorators = {
50
- [oas_types_1.SpecVersion.OAS2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas2Decorators),
51
- [oas_types_1.SpecVersion.OAS3_0]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_0Decorators),
52
- [oas_types_1.SpecVersion.OAS3_1]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_1Decorators),
53
- [oas_types_1.SpecVersion.Async2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.async2Decorators),
54
- [oas_types_1.SpecVersion.Arazzo]: Object.assign({}, rawConfig.arazzoDecorators),
52
+ [oas_types_1.SpecVersion.OAS2]: { ...rawConfig.decorators, ...rawConfig.oas2Decorators },
53
+ [oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.decorators, ...rawConfig.oas3_0Decorators },
54
+ [oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators },
55
+ [oas_types_1.SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
56
+ [oas_types_1.SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators },
57
+ [oas_types_1.SpecVersion.Arazzo]: { ...rawConfig.arazzoDecorators },
55
58
  };
56
59
  this.extendPaths = rawConfig.extendPaths || [];
57
60
  this.pluginPaths = rawConfig.pluginPaths || [];
@@ -105,7 +108,11 @@ class StyleguideConfig {
105
108
  const ruleIgnore = fileIgnore[problem.ruleId];
106
109
  const ignored = ruleIgnore && ruleIgnore.has(loc.pointer);
107
110
  return ignored
108
- ? Object.assign(Object.assign({}, problem), { ignored }) : problem;
111
+ ? {
112
+ ...problem,
113
+ ignored,
114
+ }
115
+ : problem;
109
116
  }
110
117
  extendTypes(types, version) {
111
118
  let extendedTypes = types;
@@ -128,6 +135,11 @@ class StyleguideConfig {
128
135
  continue;
129
136
  extendedTypes = plugin.typeExtension.async2(extendedTypes, version);
130
137
  break;
138
+ case oas_types_1.SpecVersion.Async3:
139
+ if (!plugin.typeExtension.async3)
140
+ continue;
141
+ extendedTypes = plugin.typeExtension.async3(extendedTypes, version);
142
+ break;
131
143
  case oas_types_1.SpecVersion.Arazzo:
132
144
  if (!plugin.typeExtension.arazzo)
133
145
  continue;
@@ -150,7 +162,7 @@ class StyleguideConfig {
150
162
  };
151
163
  }
152
164
  else {
153
- return Object.assign({ severity: 'error' }, settings);
165
+ return { severity: 'error', ...settings };
154
166
  }
155
167
  }
156
168
  getPreprocessorSettings(ruleId, oasVersion) {
@@ -163,7 +175,7 @@ class StyleguideConfig {
163
175
  };
164
176
  }
165
177
  else {
166
- return Object.assign({ severity: 'error' }, settings);
178
+ return { severity: 'error', ...settings };
167
179
  }
168
180
  }
169
181
  getDecoratorSettings(ruleId, oasVersion) {
@@ -176,7 +188,7 @@ class StyleguideConfig {
176
188
  };
177
189
  }
178
190
  else {
179
- return Object.assign({ severity: 'error' }, settings);
191
+ return { severity: 'error', ...settings };
180
192
  }
181
193
  }
182
194
  getUnusedRules() {
@@ -199,30 +211,37 @@ class StyleguideConfig {
199
211
  case oas_types_1.SpecMajorVersion.OAS3:
200
212
  // eslint-disable-next-line no-case-declarations
201
213
  const oas3Rules = []; // default ruleset
202
- this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.preprocessors.oas3); });
203
- this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.rules.oas3); });
204
- this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.decorators.oas3); });
214
+ this.plugins.forEach((p) => p.preprocessors?.oas3 && oas3Rules.push(p.preprocessors.oas3));
215
+ this.plugins.forEach((p) => p.rules?.oas3 && oas3Rules.push(p.rules.oas3));
216
+ this.plugins.forEach((p) => p.decorators?.oas3 && oas3Rules.push(p.decorators.oas3));
205
217
  return oas3Rules;
206
218
  case oas_types_1.SpecMajorVersion.OAS2:
207
219
  // eslint-disable-next-line no-case-declarations
208
220
  const oas2Rules = []; // default ruleset
209
- this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.preprocessors.oas2); });
210
- this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.rules.oas2); });
211
- this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.decorators.oas2); });
221
+ this.plugins.forEach((p) => p.preprocessors?.oas2 && oas2Rules.push(p.preprocessors.oas2));
222
+ this.plugins.forEach((p) => p.rules?.oas2 && oas2Rules.push(p.rules.oas2));
223
+ this.plugins.forEach((p) => p.decorators?.oas2 && oas2Rules.push(p.decorators.oas2));
212
224
  return oas2Rules;
213
225
  case oas_types_1.SpecMajorVersion.Async2:
214
226
  // eslint-disable-next-line no-case-declarations
215
- const asyncApiRules = []; // default ruleset
216
- this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.async2) && asyncApiRules.push(p.preprocessors.async2); });
217
- this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.async2) && asyncApiRules.push(p.rules.async2); });
218
- this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.async2) && asyncApiRules.push(p.decorators.async2); });
219
- return asyncApiRules;
227
+ const asyncApi2Rules = []; // default ruleset
228
+ this.plugins.forEach((p) => p.preprocessors?.async2 && asyncApi2Rules.push(p.preprocessors.async2));
229
+ this.plugins.forEach((p) => p.rules?.async2 && asyncApi2Rules.push(p.rules.async2));
230
+ this.plugins.forEach((p) => p.decorators?.async2 && asyncApi2Rules.push(p.decorators.async2));
231
+ return asyncApi2Rules;
232
+ case oas_types_1.SpecMajorVersion.Async3:
233
+ // eslint-disable-next-line no-case-declarations
234
+ const asyncApi3Rules = []; // default ruleset
235
+ this.plugins.forEach((p) => p.preprocessors?.async3 && asyncApi3Rules.push(p.preprocessors.async3));
236
+ this.plugins.forEach((p) => p.rules?.async3 && asyncApi3Rules.push(p.rules.async3));
237
+ this.plugins.forEach((p) => p.decorators?.async3 && asyncApi3Rules.push(p.decorators.async3));
238
+ return asyncApi3Rules;
220
239
  case oas_types_1.SpecMajorVersion.Arazzo:
221
240
  // eslint-disable-next-line no-case-declarations
222
241
  const arazzoRules = []; // default ruleset
223
- this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.preprocessors.arazzo); });
224
- this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.rules.arazzo); });
225
- this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.arazzo) && arazzoRules.push(p.decorators.arazzo); });
242
+ this.plugins.forEach((p) => p.preprocessors?.arazzo && arazzoRules.push(p.preprocessors.arazzo));
243
+ this.plugins.forEach((p) => p.rules?.arazzo && arazzoRules.push(p.rules.arazzo));
244
+ this.plugins.forEach((p) => p.decorators?.arazzo && arazzoRules.push(p.decorators.arazzo));
226
245
  return arazzoRules;
227
246
  }
228
247
  }
@@ -262,7 +281,7 @@ class Config {
262
281
  this.apis = rawConfig.apis || {};
263
282
  this.styleguide = new StyleguideConfig(rawConfig.styleguide || {}, configFile);
264
283
  this.theme = rawConfig.theme || {};
265
- this.resolve = (0, utils_2.getResolveConfig)(rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve);
284
+ this.resolve = (0, utils_2.getResolveConfig)(rawConfig?.resolve);
266
285
  this.region = rawConfig.region;
267
286
  this.organization = rawConfig.organization;
268
287
  this.files = rawConfig.files || [];
@@ -1,9 +1,8 @@
1
1
  import { Config } from './config';
2
2
  import { BaseResolver } from '../resolve';
3
- import type { Document } from '../resolve';
3
+ import type { Document, ResolvedRefMap } from '../resolve';
4
4
  import type { RegionalTokenWithValidity } from '../redocly/redocly-client-types';
5
5
  import type { RawConfig, RawUniversalConfig, Region } from './types';
6
- import type { ResolvedRefMap } from '../resolve';
7
6
  export type RawConfigProcessor = (params: {
8
7
  document: Document;
9
8
  resolvedRefMap: ResolvedRefMap;