@redocly/openapi-core 0.0.0-snapshot.1740665575 → 0.0.0-snapshot.1742384755

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 (54) hide show
  1. package/README.md +2 -2
  2. package/lib/bundle.d.ts +0 -2
  3. package/lib/bundle.js +8 -8
  4. package/lib/config/all.js +3 -0
  5. package/lib/config/builtIn.js +5 -3
  6. package/lib/config/config-resolvers.js +47 -13
  7. package/lib/config/config.d.ts +3 -6
  8. package/lib/config/config.js +20 -7
  9. package/lib/config/load.d.ts +1 -5
  10. package/lib/config/load.js +4 -43
  11. package/lib/config/minimal.js +3 -0
  12. package/lib/config/recommended-strict.js +3 -0
  13. package/lib/config/recommended.js +3 -0
  14. package/lib/config/rules.d.ts +2 -2
  15. package/lib/config/spec.js +3 -0
  16. package/lib/config/types.d.ts +8 -10
  17. package/lib/config/utils.js +15 -2
  18. package/lib/decorators/oas2/index.d.ts +0 -1
  19. package/lib/decorators/oas2/index.js +0 -2
  20. package/lib/decorators/oas3/index.d.ts +0 -1
  21. package/lib/decorators/oas3/index.js +0 -2
  22. package/lib/decorators/overlay1/index.d.ts +1 -0
  23. package/lib/{redocly/redocly-client-types.js → decorators/overlay1/index.js} +2 -0
  24. package/lib/index.d.ts +1 -3
  25. package/lib/index.js +2 -19
  26. package/lib/oas-types.d.ts +9 -4
  27. package/lib/oas-types.js +10 -0
  28. package/lib/rules/async3/no-channel-trailing-slash.js +1 -1
  29. package/lib/rules/common/assertions/index.d.ts +2 -2
  30. package/lib/rules/common/no-invalid-schema-examples.d.ts +2 -1
  31. package/lib/rules/common/no-invalid-schema-examples.js +10 -3
  32. package/lib/rules/common/struct.d.ts +2 -2
  33. package/lib/rules/overlay1/index.d.ts +3 -0
  34. package/lib/rules/overlay1/index.js +12 -0
  35. package/lib/rules/respect/respect-supported-versions.js +1 -1
  36. package/lib/types/oas2.js +1 -1
  37. package/lib/types/oas3.js +1 -1
  38. package/lib/types/redocly-yaml.d.ts +2 -0
  39. package/lib/types/redocly-yaml.js +4 -16
  40. package/lib/typings/openapi.d.ts +2 -2
  41. package/lib/utils.js +7 -8
  42. package/lib/visitors.d.ts +11 -0
  43. package/package.json +9 -6
  44. package/lib/decorators/common/registry-dependencies.d.ts +0 -2
  45. package/lib/decorators/common/registry-dependencies.js +0 -24
  46. package/lib/redocly/domains.d.ts +0 -14
  47. package/lib/redocly/domains.js +0 -41
  48. package/lib/redocly/index.d.ts +0 -30
  49. package/lib/redocly/index.js +0 -131
  50. package/lib/redocly/redocly-client-types.d.ts +0 -8
  51. package/lib/redocly/registry-api-types.d.ts +0 -29
  52. package/lib/redocly/registry-api-types.js +0 -2
  53. package/lib/redocly/registry-api.d.ts +0 -17
  54. package/lib/redocly/registry-api.js +0 -100
package/README.md CHANGED
@@ -12,7 +12,7 @@ See https://github.com/Redocly/redocly-cli
12
12
 
13
13
  ### Lint from file system
14
14
 
15
- [Lint](https://redocly.com/docs/cli/commands/lint/) a file, optionally with a [config file](https://redocly.com/docs/cli/configuration/).
15
+ [Lint](https://redocly.com/docs/cli/commands/lint/) a file.
16
16
 
17
17
  ```js
18
18
  import { lint, loadConfig } from '@redocly/openapi-core';
@@ -28,7 +28,7 @@ To learn more, [check the `lint` function section](#lint).
28
28
 
29
29
  ### Bundle from file system
30
30
 
31
- [Bundle](https://redocly.com/docs/cli/commands/bundle/) an API description into a single structure, optionally with a [config file](https://redocly.com/docs/cli/configuration/).
31
+ [Bundle](https://redocly.com/docs/cli/commands/bundle/) an API description into a single structure.
32
32
 
33
33
  ```js
34
34
  import { bundle, loadConfig } from '@redocly/openapi-core';
package/lib/bundle.d.ts CHANGED
@@ -15,7 +15,6 @@ export type BundleOptions = {
15
15
  config: Config;
16
16
  dereference?: boolean;
17
17
  base?: string | null;
18
- skipRedoclyRegistryRefs?: boolean;
19
18
  removeUnusedComponents?: boolean;
20
19
  keepUrlRefs?: boolean;
21
20
  };
@@ -43,7 +42,6 @@ export declare function bundleDocument(opts: {
43
42
  customTypes?: Record<string, NodeType>;
44
43
  externalRefResolver: BaseResolver;
45
44
  dereference?: boolean;
46
- skipRedoclyRegistryRefs?: boolean;
47
45
  removeUnusedComponents?: boolean;
48
46
  keepUrlRefs?: boolean;
49
47
  }): Promise<BundleResult>;
package/lib/bundle.js CHANGED
@@ -15,7 +15,6 @@ const ref_utils_1 = require("./ref-utils");
15
15
  const rules_1 = require("./config/rules");
16
16
  const no_unresolved_refs_1 = require("./rules/no-unresolved-refs");
17
17
  const utils_1 = require("./utils");
18
- const domains_1 = require("./redocly/domains");
19
18
  const remove_unused_components_1 = require("./decorators/oas2/remove-unused-components");
20
19
  const remove_unused_components_2 = require("./decorators/oas3/remove-unused-components");
21
20
  const redocly_yaml_1 = require("./types/redocly-yaml");
@@ -83,7 +82,7 @@ async function bundleFromString(opts) {
83
82
  });
84
83
  }
85
84
  async function bundleDocument(opts) {
86
- const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
85
+ const { document, config, customTypes, externalRefResolver, dereference = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
87
86
  const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
88
87
  const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
89
88
  const rules = config.getRulesForSpecVersion(specMajorVersion);
@@ -129,7 +128,7 @@ async function bundleDocument(opts) {
129
128
  {
130
129
  severity: 'error',
131
130
  ruleId: 'bundler',
132
- visitor: makeBundleVisitor(specMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
131
+ visitor: makeBundleVisitor(specMajorVersion, dereference, document, resolvedRefMap, keepUrlRefs),
133
132
  },
134
133
  ...decorators,
135
134
  ], types);
@@ -211,6 +210,11 @@ function mapTypeToComponent(typeName, version) {
211
210
  default:
212
211
  return null;
213
212
  }
213
+ case oas_types_1.SpecMajorVersion.Overlay1:
214
+ switch (typeName) {
215
+ default:
216
+ return null;
217
+ }
214
218
  }
215
219
  }
216
220
  function replaceRef(ref, resolved, ctx) {
@@ -226,7 +230,7 @@ function replaceRef(ref, resolved, ctx) {
226
230
  }
227
231
  }
228
232
  // function oas3Move
229
- function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDocument, resolvedRefMap, keepUrlRefs) {
233
+ function makeBundleVisitor(version, dereference, rootDocument, resolvedRefMap, keepUrlRefs) {
230
234
  let components;
231
235
  let rootLocation;
232
236
  const visitor = {
@@ -242,10 +246,6 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
242
246
  !dereference) {
243
247
  return;
244
248
  }
245
- // do not bundle registry URL before push, otherwise we can't record dependencies
246
- if (skipRedoclyRegistryRefs && (0, domains_1.isRedoclyRegistryURL)(node.$ref)) {
247
- return;
248
- }
249
249
  if (keepUrlRefs && (0, ref_utils_1.isAbsoluteUrl)(node.$ref)) {
250
250
  return;
251
251
  }
package/lib/config/all.js CHANGED
@@ -226,5 +226,8 @@ const all = {
226
226
  'workflowId-unique': 'error',
227
227
  'workflow-dependsOn': 'error',
228
228
  },
229
+ overlay1Rules: {
230
+ 'info-contact': 'error',
231
+ },
229
232
  };
230
233
  exports.default = all;
@@ -11,20 +11,19 @@ const oas2_1 = require("../rules/oas2");
11
11
  const async2_1 = require("../rules/async2");
12
12
  const async3_1 = require("../rules/async3");
13
13
  const arazzo_1 = require("../rules/arazzo");
14
+ const overlay1_1 = require("../rules/overlay1");
14
15
  const oas3_2 = require("../decorators/oas3");
15
16
  const oas2_2 = require("../decorators/oas2");
16
17
  const async2_2 = require("../decorators/async2");
17
18
  const async3_2 = require("../decorators/async3");
18
19
  const arazzo_2 = require("../decorators/arazzo");
20
+ const overlay1_2 = require("../decorators/overlay1");
19
21
  exports.builtInConfigs = {
20
22
  recommended: recommended_1.default,
21
23
  'recommended-strict': recommended_strict_1.default,
22
24
  minimal: minimal_1.default,
23
25
  all: all_1.default,
24
26
  spec: spec_1.default,
25
- 'redocly-registry': {
26
- decorators: { 'registry-dependencies': 'on' },
27
- },
28
27
  };
29
28
  exports.defaultPlugin = {
30
29
  id: '', // default plugin doesn't have id
@@ -34,6 +33,7 @@ exports.defaultPlugin = {
34
33
  async2: async2_1.rules,
35
34
  async3: async3_1.rules,
36
35
  arazzo1: arazzo_1.rules,
36
+ overlay1: overlay1_1.rules,
37
37
  },
38
38
  preprocessors: {
39
39
  oas3: oas3_1.preprocessors,
@@ -41,6 +41,7 @@ exports.defaultPlugin = {
41
41
  async2: async2_1.preprocessors,
42
42
  async3: async3_1.preprocessors,
43
43
  arazzo1: arazzo_1.preprocessors,
44
+ overlay1: overlay1_1.preprocessors,
44
45
  },
45
46
  decorators: {
46
47
  oas3: oas3_2.decorators,
@@ -48,6 +49,7 @@ exports.defaultPlugin = {
48
49
  async2: async2_2.decorators,
49
50
  async3: async3_2.decorators,
50
51
  arazzo1: arazzo_2.decorators,
52
+ overlay1: overlay1_2.decorators,
51
53
  },
52
54
  configs: exports.builtInConfigs,
53
55
  };
@@ -91,18 +91,24 @@ async function resolvePlugins(plugins, configDir = '') {
91
91
  if (!pluginsCache.has(absolutePluginPath)) {
92
92
  let requiredPlugin;
93
93
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
94
- // @ts-ignore
94
+ // @ts-ignore FIXME: remove?
95
95
  if (typeof __webpack_require__ === 'function') {
96
96
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97
- // @ts-ignore
97
+ // @ts-ignore FIXME: remove?
98
98
  requiredPlugin = __non_webpack_require__(absolutePluginPath);
99
99
  }
100
100
  else {
101
- // Workaround for dynamic imports being transpiled to require by Typescript: https://github.com/microsoft/TypeScript/issues/43329#issuecomment-811606238
102
- const _importDynamic = new Function('modulePath', 'return import(modulePath)');
103
- // you can import both cjs and mjs
104
- const mod = await _importDynamic((0, url_1.pathToFileURL)(absolutePluginPath).href);
105
- requiredPlugin = mod.default || mod;
101
+ // FIXME: fix this mess after we migrate to ESM
102
+ try {
103
+ // Workaround for dynamic imports being transpiled to require by Typescript: https://github.com/microsoft/TypeScript/issues/43329#issuecomment-811606238
104
+ const _importDynamic = new Function('modulePath', 'return import(modulePath)');
105
+ const mod = await _importDynamic((0, url_1.pathToFileURL)(absolutePluginPath).href);
106
+ requiredPlugin = mod.default || mod;
107
+ }
108
+ catch (e) {
109
+ const mod = await Promise.resolve(`${(0, url_1.pathToFileURL)(absolutePluginPath).href}`).then(s => require(s));
110
+ requiredPlugin = mod.default || mod;
111
+ }
106
112
  }
107
113
  const pluginCreatorOptions = { contentDir: configDir };
108
114
  const pluginModule = (0, utils_2.isDeprecatedPluginFormat)(requiredPlugin)
@@ -167,8 +173,13 @@ async function resolvePlugins(plugins, configDir = '') {
167
173
  ...(pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}),
168
174
  };
169
175
  if (pluginModule.rules) {
170
- if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
171
- throw new Error(`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\` or \`arazzo\` rules "${p}.`);
176
+ if (!pluginModule.rules.oas3 &&
177
+ !pluginModule.rules.oas2 &&
178
+ !pluginModule.rules.async2 &&
179
+ !pluginModule.rules.async3 &&
180
+ !pluginModule.rules.arazzo1 &&
181
+ !pluginModule.rules.overlay1) {
182
+ throw new Error(`Plugin rules must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo\`, or \`overlay1\` rules "${p}.`);
172
183
  }
173
184
  plugin.rules = {};
174
185
  if (pluginModule.rules.oas3) {
@@ -186,14 +197,18 @@ async function resolvePlugins(plugins, configDir = '') {
186
197
  if (pluginModule.rules.arazzo1) {
187
198
  plugin.rules.arazzo1 = (0, utils_2.prefixRules)(pluginModule.rules.arazzo1, id);
188
199
  }
200
+ if (pluginModule.rules.overlay1) {
201
+ plugin.rules.overlay1 = (0, utils_2.prefixRules)(pluginModule.rules.overlay1, id);
202
+ }
189
203
  }
190
204
  if (pluginModule.preprocessors) {
191
205
  if (!pluginModule.preprocessors.oas3 &&
192
206
  !pluginModule.preprocessors.oas2 &&
193
207
  !pluginModule.preprocessors.async2 &&
194
208
  !pluginModule.preprocessors.async3 &&
195
- !pluginModule.preprocessors.arazzo1) {
196
- throw new Error(`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`);
209
+ !pluginModule.preprocessors.arazzo1 &&
210
+ !pluginModule.preprocessors.overlay1) {
211
+ throw new Error(`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo1\`, or \`overlay1\` preprocessors "${p}.`);
197
212
  }
198
213
  plugin.preprocessors = {};
199
214
  if (pluginModule.preprocessors.oas3) {
@@ -211,14 +226,18 @@ async function resolvePlugins(plugins, configDir = '') {
211
226
  if (pluginModule.preprocessors.arazzo1) {
212
227
  plugin.preprocessors.arazzo1 = (0, utils_2.prefixRules)(pluginModule.preprocessors.arazzo1, id);
213
228
  }
229
+ if (pluginModule.preprocessors.overlay1) {
230
+ plugin.preprocessors.overlay1 = (0, utils_2.prefixRules)(pluginModule.preprocessors.overlay1, id);
231
+ }
214
232
  }
215
233
  if (pluginModule.decorators) {
216
234
  if (!pluginModule.decorators.oas3 &&
217
235
  !pluginModule.decorators.oas2 &&
218
236
  !pluginModule.decorators.async2 &&
219
237
  !pluginModule.decorators.async3 &&
220
- !pluginModule.decorators.arazzo1) {
221
- throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\` or \`async3\` decorators "${p}.`);
238
+ !pluginModule.decorators.arazzo1 &&
239
+ !pluginModule.decorators.overlay1) {
240
+ throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\`, \`async2\`, \`async3\`, \`arazzo1\`, or \`overlay1\` decorators "${p}.`);
222
241
  }
223
242
  plugin.decorators = {};
224
243
  if (pluginModule.decorators.oas3) {
@@ -236,6 +255,9 @@ async function resolvePlugins(plugins, configDir = '') {
236
255
  if (pluginModule.decorators.arazzo1) {
237
256
  plugin.decorators.arazzo1 = (0, utils_2.prefixRules)(pluginModule.decorators.arazzo1, id);
238
257
  }
258
+ if (pluginModule.decorators.overlay1) {
259
+ plugin.decorators.overlay1 = (0, utils_2.prefixRules)(pluginModule.decorators.overlay1, id);
260
+ }
239
261
  }
240
262
  if (pluginModule.assertions) {
241
263
  plugin.assertions = pluginModule.assertions;
@@ -359,6 +381,10 @@ function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig)
359
381
  async2Rules: { ...rootStyleguideConfig?.async2Rules, ...apiStyleguideConfig?.async2Rules },
360
382
  async3Rules: { ...rootStyleguideConfig?.async3Rules, ...apiStyleguideConfig?.async3Rules },
361
383
  arazzo1Rules: { ...rootStyleguideConfig?.arazzo1Rules, ...apiStyleguideConfig?.arazzo1Rules },
384
+ overlay1Rules: {
385
+ ...rootStyleguideConfig?.overlay1Rules,
386
+ ...apiStyleguideConfig?.overlay1Rules,
387
+ },
362
388
  preprocessors: {
363
389
  ...rootStyleguideConfig?.preprocessors,
364
390
  ...apiStyleguideConfig?.preprocessors,
@@ -375,6 +401,10 @@ function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig)
375
401
  ...rootStyleguideConfig?.oas3_1Preprocessors,
376
402
  ...apiStyleguideConfig?.oas3_1Preprocessors,
377
403
  },
404
+ overlay1Preprocessors: {
405
+ ...rootStyleguideConfig?.overlay1Preprocessors,
406
+ ...apiStyleguideConfig?.overlay1Preprocessors,
407
+ },
378
408
  decorators: { ...rootStyleguideConfig?.decorators, ...apiStyleguideConfig?.decorators },
379
409
  oas2Decorators: {
380
410
  ...rootStyleguideConfig?.oas2Decorators,
@@ -388,6 +418,10 @@ function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig)
388
418
  ...rootStyleguideConfig?.oas3_1Decorators,
389
419
  ...apiStyleguideConfig?.oas3_1Decorators,
390
420
  },
421
+ overlay1Decorators: {
422
+ ...rootStyleguideConfig?.overlay1Decorators,
423
+ ...apiStyleguideConfig?.overlay1Decorators,
424
+ },
391
425
  recommendedFallback: apiStyleguideConfig?.extends
392
426
  ? false
393
427
  : rootStyleguideConfig.recommendedFallback,
@@ -1,8 +1,8 @@
1
1
  import { SpecVersion, SpecMajorVersion } from '../oas-types';
2
2
  import type { NormalizedProblem } from '../walk';
3
- import type { Oas2RuleSet, Oas3RuleSet, Async3RuleSet, Arazzo1RuleSet } from '../oas-types';
3
+ import type { Oas2RuleSet, Oas3RuleSet, Async3RuleSet, Arazzo1RuleSet, Overlay1RuleSet } from '../oas-types';
4
4
  import type { NodeType } from '../types';
5
- import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types';
5
+ import type { DecoratorConfig, Plugin, PreprocessorConfig, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types';
6
6
  export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
7
7
  export declare class StyleguideConfig {
8
8
  rawConfig: ResolvedStyleguideConfig;
@@ -32,7 +32,7 @@ export declare class StyleguideConfig {
32
32
  preprocessors: string[];
33
33
  decorators: string[];
34
34
  };
35
- getRulesForSpecVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async3RuleSet[] | Arazzo1RuleSet[];
35
+ getRulesForSpecVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async3RuleSet[] | Arazzo1RuleSet[] | Overlay1RuleSet[];
36
36
  skipRules(rules?: string[]): void;
37
37
  skipPreprocessors(preprocessors?: string[]): void;
38
38
  skipDecorators(decorators?: string[]): void;
@@ -44,10 +44,7 @@ export declare class Config {
44
44
  styleguide: StyleguideConfig;
45
45
  resolve: ResolveConfig;
46
46
  licenseKey?: string;
47
- region?: Region;
48
47
  theme: ThemeRawConfig;
49
- organization?: string;
50
- files: string[];
51
48
  telemetry?: Telemetry;
52
49
  constructor(rawConfig: ResolvedConfig, configFile?: string | undefined);
53
50
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Config = exports.StyleguideConfig = exports.IGNORE_FILE = void 0;
4
- const fs = require("fs");
5
- const path = require("path");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
6
  const js_yaml_1 = require("../js-yaml");
7
7
  const utils_1 = require("../utils");
8
8
  const oas_types_1 = require("../oas-types");
@@ -40,6 +40,7 @@ class StyleguideConfig {
40
40
  'async2Rules',
41
41
  'async3Rules',
42
42
  'arazzo1Rules',
43
+ 'overlay1Rules',
43
44
  ];
44
45
  replaceSpecWithStruct(ruleGroups, rawConfig);
45
46
  this.rules = {
@@ -49,6 +50,7 @@ class StyleguideConfig {
49
50
  [oas_types_1.SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules },
50
51
  [oas_types_1.SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules },
51
52
  [oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.rules, ...rawConfig.arazzo1Rules },
53
+ [oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.rules, ...rawConfig.overlay1Rules },
52
54
  };
53
55
  this.preprocessors = {
54
56
  [oas_types_1.SpecVersion.OAS2]: { ...rawConfig.preprocessors, ...rawConfig.oas2Preprocessors },
@@ -57,6 +59,7 @@ class StyleguideConfig {
57
59
  [oas_types_1.SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors },
58
60
  [oas_types_1.SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors },
59
61
  [oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Preprocessors },
62
+ [oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.preprocessors, ...rawConfig.overlay1Preprocessors },
60
63
  };
61
64
  this.decorators = {
62
65
  [oas_types_1.SpecVersion.OAS2]: { ...rawConfig.decorators, ...rawConfig.oas2Decorators },
@@ -65,6 +68,7 @@ class StyleguideConfig {
65
68
  [oas_types_1.SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators },
66
69
  [oas_types_1.SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators },
67
70
  [oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Decorators },
71
+ [oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.decorators, ...rawConfig.overlay1Decorators },
68
72
  };
69
73
  this.extendPaths = rawConfig.extendPaths || [];
70
74
  this.pluginPaths = rawConfig.pluginPaths || [];
@@ -75,7 +79,7 @@ class StyleguideConfig {
75
79
  return;
76
80
  this.ignore =
77
81
  (0, js_yaml_1.parseYaml)(fs.readFileSync(ignoreFile, 'utf-8')) || {};
78
- replaceSpecWithStruct(Object.keys(this.ignore), this.ignore);
82
+ replaceSpecWithStruct(Object.keys(this.ignore), this.ignore); // FIXME: remove this
79
83
  // resolve ignore paths
80
84
  for (const fileName of Object.keys(this.ignore)) {
81
85
  this.ignore[(0, ref_utils_1.isAbsoluteUrl)(fileName) ? fileName : path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName];
@@ -156,6 +160,11 @@ class StyleguideConfig {
156
160
  continue;
157
161
  extendedTypes = plugin.typeExtension.arazzo1(extendedTypes, version);
158
162
  break;
163
+ case oas_types_1.SpecVersion.Overlay1:
164
+ if (!plugin.typeExtension.overlay1)
165
+ continue;
166
+ extendedTypes = plugin.typeExtension.overlay1(extendedTypes, version);
167
+ break;
159
168
  default:
160
169
  throw new Error('Not implemented');
161
170
  }
@@ -254,6 +263,13 @@ class StyleguideConfig {
254
263
  this.plugins.forEach((p) => p.rules?.arazzo1 && arazzo1Rules.push(p.rules.arazzo1));
255
264
  this.plugins.forEach((p) => p.decorators?.arazzo1 && arazzo1Rules.push(p.decorators.arazzo1));
256
265
  return arazzo1Rules;
266
+ case oas_types_1.SpecMajorVersion.Overlay1:
267
+ // eslint-disable-next-line no-case-declarations
268
+ const overlay1Rules = [];
269
+ this.plugins.forEach((p) => p.preprocessors?.overlay1 && overlay1Rules.push(p.preprocessors.overlay1));
270
+ this.plugins.forEach((p) => p.rules?.overlay1 && overlay1Rules.push(p.rules.overlay1));
271
+ this.plugins.forEach((p) => p.decorators?.overlay1 && overlay1Rules.push(p.decorators.overlay1));
272
+ return overlay1Rules;
257
273
  }
258
274
  }
259
275
  skipRules(rules) {
@@ -309,11 +325,8 @@ class Config {
309
325
  this.configFile = configFile;
310
326
  this.apis = rawConfig.apis || {};
311
327
  this.styleguide = new StyleguideConfig(rawConfig.styleguide || {}, configFile);
312
- this.theme = rawConfig.theme || {};
328
+ this.theme = rawConfig.theme || {}; // FIXME: theme is deprecated
313
329
  this.resolve = (0, utils_2.getResolveConfig)(rawConfig?.resolve);
314
- this.region = rawConfig.region;
315
- this.organization = rawConfig.organization;
316
- this.files = rawConfig.files || [];
317
330
  this.telemetry = rawConfig.telemetry;
318
331
  }
319
332
  }
@@ -1,8 +1,7 @@
1
1
  import { BaseResolver } from '../resolve';
2
2
  import type { Config } from './config';
3
3
  import type { Document, ResolvedRefMap } from '../resolve';
4
- import type { RegionalTokenWithValidity } from '../redocly/redocly-client-types';
5
- import type { RawConfig, RawUniversalConfig, Region } from './types';
4
+ import type { RawConfig, RawUniversalConfig } from './types';
6
5
  export type RawConfigProcessor = (params: {
7
6
  document: Document;
8
7
  resolvedRefMap: ResolvedRefMap;
@@ -14,8 +13,6 @@ export declare function loadConfig(options?: {
14
13
  customExtends?: string[];
15
14
  processRawConfig?: RawConfigProcessor;
16
15
  externalRefResolver?: BaseResolver;
17
- files?: string[];
18
- region?: Region;
19
16
  }): Promise<Config>;
20
17
  export declare const CONFIG_FILE_NAMES: string[];
21
18
  export declare function findConfig(dir?: string): string | undefined;
@@ -30,7 +27,6 @@ export declare function getConfig(options?: {
30
27
  }>;
31
28
  type CreateConfigOptions = {
32
29
  extends?: string[];
33
- tokens?: RegionalTokenWithValidity[];
34
30
  configPath?: string;
35
31
  externalRefResolver?: BaseResolver;
36
32
  };
@@ -7,16 +7,13 @@ exports.getConfig = getConfig;
7
7
  exports.createConfig = createConfig;
8
8
  const fs = require("fs");
9
9
  const path = require("path");
10
- const redocly_1 = require("../redocly");
11
10
  const utils_1 = require("../utils");
12
11
  const js_yaml_1 = require("../js-yaml");
13
12
  const utils_2 = require("./utils");
14
13
  const config_resolvers_1 = require("./config-resolvers");
15
14
  const bundle_1 = require("../bundle");
16
15
  const resolve_1 = require("../resolve");
17
- const env_1 = require("../env");
18
- const domains_1 = require("../redocly/domains");
19
- async function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, files, region, externalRefResolver, }) {
16
+ async function addConfigMetadata({ rawConfig, customExtends, configPath, externalRefResolver, }) {
20
17
  if (customExtends !== undefined) {
21
18
  rawConfig.styleguide = rawConfig.styleguide || {};
22
19
  rawConfig.styleguide.extends = customExtends;
@@ -24,58 +21,22 @@ async function addConfigMetadata({ rawConfig, customExtends, configPath, tokens,
24
21
  else if ((0, utils_1.isEmptyObject)(rawConfig)) {
25
22
  rawConfig.styleguide = { extends: ['recommended'], recommendedFallback: true };
26
23
  }
27
- if (tokens?.length) {
28
- if (!rawConfig.resolve)
29
- rawConfig.resolve = {};
30
- if (!rawConfig.resolve.http)
31
- rawConfig.resolve.http = {};
32
- rawConfig.resolve.http.headers = [...(rawConfig.resolve.http.headers ?? [])];
33
- for (const item of tokens) {
34
- const domain = domains_1.DOMAINS[item.region];
35
- rawConfig.resolve.http.headers.push({
36
- matches: `https://api.${domain}/registry/**`,
37
- name: 'Authorization',
38
- envVariable: undefined,
39
- value: item.token,
40
- },
41
- //support redocly.com domain for future compatibility
42
- ...(item.region === 'us'
43
- ? [
44
- {
45
- matches: `https://api.redoc.ly/registry/**`,
46
- name: 'Authorization',
47
- envVariable: undefined,
48
- value: item.token,
49
- },
50
- ]
51
- : []));
52
- }
53
- }
54
24
  return (0, config_resolvers_1.resolveConfig)({
55
- rawConfig: {
56
- ...rawConfig,
57
- files: files ?? rawConfig.files,
58
- region: region ?? rawConfig.region,
59
- },
25
+ rawConfig,
60
26
  configPath,
61
27
  externalRefResolver,
62
28
  });
63
29
  }
64
30
  async function loadConfig(options = {}) {
65
- const { configPath = findConfig(), customExtends, processRawConfig, files, region, externalRefResolver, } = options;
31
+ const { configPath = findConfig(), customExtends, processRawConfig, externalRefResolver, } = options;
66
32
  const { rawConfig, document, parsed, resolvedRefMap } = await getConfig({
67
33
  configPath,
68
34
  externalRefResolver,
69
35
  });
70
- const redoclyClient = env_1.isBrowser ? undefined : new redocly_1.RedoclyClient();
71
- const tokens = redoclyClient && redoclyClient.hasTokens() ? redoclyClient.getAllTokens() : [];
72
36
  const config = await addConfigMetadata({
73
37
  rawConfig,
74
38
  customExtends,
75
39
  configPath,
76
- tokens,
77
- files,
78
- region,
79
40
  externalRefResolver,
80
41
  });
81
42
  if (document && parsed && resolvedRefMap && typeof processRawConfig === 'function') {
@@ -98,7 +59,7 @@ async function loadConfig(options = {}) {
98
59
  }
99
60
  exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml'];
100
61
  function findConfig(dir) {
101
- if (!fs?.hasOwnProperty?.('existsSync'))
62
+ if (!fs?.existsSync)
102
63
  return;
103
64
  const existingConfigFiles = exports.CONFIG_FILE_NAMES.map((name) => dir ? path.resolve(dir, name) : name).filter(fs.existsSync);
104
65
  if (existingConfigFiles.length > 1) {
@@ -202,5 +202,8 @@ const minimal = {
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'off',
204
204
  },
205
+ overlay1Rules: {
206
+ 'info-contact': 'off',
207
+ },
205
208
  };
206
209
  exports.default = minimal;
@@ -202,5 +202,8 @@ const recommendedStrict = {
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
205
+ overlay1Rules: {
206
+ 'info-contact': 'off',
207
+ },
205
208
  };
206
209
  exports.default = recommendedStrict;
@@ -202,5 +202,8 @@ const recommended = {
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
205
+ overlay1Rules: {
206
+ 'info-contact': 'off',
207
+ },
205
208
  };
206
209
  exports.default = recommended;
@@ -1,4 +1,4 @@
1
- import type { Arazzo1RuleSet, Async2RuleSet, Async3RuleSet, Oas2RuleSet, Oas3RuleSet, SpecVersion } from '../oas-types';
1
+ import type { Arazzo1RuleSet, Async2RuleSet, Async3RuleSet, Oas2RuleSet, Oas3RuleSet, Overlay1RuleSet, SpecVersion } from '../oas-types';
2
2
  import type { StyleguideConfig } from './config';
3
3
  import type { ProblemSeverity } from '../walk';
4
4
  type InitializedRule = {
@@ -6,5 +6,5 @@ type InitializedRule = {
6
6
  ruleId: string;
7
7
  visitor: any;
8
8
  };
9
- export declare function initRules(rules: (Oas3RuleSet | Oas2RuleSet | Async2RuleSet | Async3RuleSet | Arazzo1RuleSet)[], config: StyleguideConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: SpecVersion): InitializedRule[];
9
+ export declare function initRules(rules: (Oas3RuleSet | Oas2RuleSet | Async2RuleSet | Async3RuleSet | Arazzo1RuleSet | Overlay1RuleSet)[], config: StyleguideConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: SpecVersion): InitializedRule[];
10
10
  export {};
@@ -25,5 +25,8 @@ const spec = {
25
25
  'no-criteria-xpath': 'off',
26
26
  'criteria-unique': 'error',
27
27
  },
28
+ overlay1Rules: {
29
+ 'info-contact': 'warn',
30
+ },
28
31
  };
29
32
  exports.default = spec;