@redocly/openapi-core 1.18.1 → 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 (139) hide show
  1. package/CHANGELOG.md +10 -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 +2 -2
  11. package/lib/bundle.js +127 -120
  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.js +105 -117
  18. package/lib/config/minimal.js +9 -0
  19. package/lib/config/recommended-strict.js +9 -0
  20. package/lib/config/recommended.js +9 -0
  21. package/lib/config/rules.d.ts +3 -3
  22. package/lib/config/rules.js +1 -2
  23. package/lib/config/types.d.ts +9 -3
  24. package/lib/config/utils.js +70 -49
  25. package/lib/decorators/async3/index.d.ts +1 -0
  26. package/lib/decorators/async3/index.js +4 -0
  27. package/lib/decorators/common/filters/filter-helper.js +2 -3
  28. package/lib/decorators/common/filters/filter-in.js +1 -1
  29. package/lib/decorators/common/filters/filter-out.js +1 -1
  30. package/lib/decorators/common/info-override.js +1 -12
  31. package/lib/decorators/common/media-type-examples-override.js +8 -2
  32. package/lib/decorators/common/remove-x-internal.js +4 -5
  33. package/lib/decorators/oas2/remove-unused-components.js +1 -2
  34. package/lib/decorators/oas3/remove-unused-components.js +1 -2
  35. package/lib/env.d.ts +0 -1
  36. package/lib/env.js +1 -1
  37. package/lib/format/codeframes.js +10 -8
  38. package/lib/format/format.js +23 -15
  39. package/lib/index.d.ts +2 -1
  40. package/lib/index.js +6 -4
  41. package/lib/js-yaml/index.js +1 -1
  42. package/lib/lint.d.ts +2 -0
  43. package/lib/lint.js +92 -99
  44. package/lib/oas-types.d.ts +9 -5
  45. package/lib/oas-types.js +22 -12
  46. package/lib/redocly/domains.js +6 -6
  47. package/lib/redocly/index.js +60 -73
  48. package/lib/redocly/registry-api.js +64 -82
  49. package/lib/ref-utils.js +13 -13
  50. package/lib/resolve.js +186 -205
  51. package/lib/rules/ajv.js +10 -8
  52. package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
  53. package/lib/rules/async3/channels-kebab-case.js +19 -0
  54. package/lib/rules/async3/index.d.ts +3 -0
  55. package/lib/rules/async3/index.js +22 -0
  56. package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
  57. package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
  58. package/lib/rules/common/assertions/asserts.js +5 -5
  59. package/lib/rules/common/assertions/index.d.ts +5 -4
  60. package/lib/rules/common/assertions/utils.js +43 -28
  61. package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
  62. package/lib/rules/common/no-invalid-schema-examples.js +1 -2
  63. package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
  64. package/lib/rules/common/operation-tag-defined.js +1 -2
  65. package/lib/rules/common/path-http-verbs-order.js +1 -1
  66. package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
  67. package/lib/rules/common/response-contains-header.js +2 -2
  68. package/lib/rules/common/security-defined.js +3 -7
  69. package/lib/rules/common/spec.d.ts +2 -2
  70. package/lib/rules/common/spec.js +6 -7
  71. package/lib/rules/no-unresolved-refs.js +3 -4
  72. package/lib/rules/oas2/response-contains-property.js +1 -2
  73. package/lib/rules/oas3/array-parameter-serialization.js +1 -2
  74. package/lib/rules/oas3/component-name-unique.js +2 -4
  75. package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
  76. package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
  77. package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
  78. package/lib/rules/oas3/no-unused-components.js +1 -2
  79. package/lib/rules/oas3/response-contains-property.js +1 -2
  80. package/lib/rules/utils.js +14 -12
  81. package/lib/types/asyncapi2.d.ts +17 -0
  82. package/lib/types/{asyncapi.js → asyncapi2.js} +56 -52
  83. package/lib/types/asyncapi3.d.ts +2 -0
  84. package/lib/types/asyncapi3.js +347 -0
  85. package/lib/types/index.js +19 -10
  86. package/lib/types/json-schema-adapter.js +4 -18
  87. package/lib/types/oas2.js +6 -6
  88. package/lib/types/oas3.js +10 -10
  89. package/lib/types/oas3_1.js +14 -8
  90. package/lib/types/redocly-yaml.d.ts +3 -1
  91. package/lib/types/redocly-yaml.js +131 -35
  92. package/lib/typings/asyncapi3.d.ts +53 -0
  93. package/lib/typings/asyncapi3.js +2 -0
  94. package/lib/utils.d.ts +4 -3
  95. package/lib/utils.js +55 -72
  96. package/lib/visitors.d.ts +11 -0
  97. package/lib/visitors.js +21 -8
  98. package/lib/walk.js +30 -23
  99. package/package.json +2 -2
  100. package/src/__tests__/bundle.test.ts +142 -0
  101. package/src/bundle.ts +17 -3
  102. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +22 -0
  103. package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
  104. package/src/config/__tests__/config.test.ts +11 -0
  105. package/src/config/all.ts +9 -0
  106. package/src/config/builtIn.ts +6 -0
  107. package/src/config/config-resolvers.ts +15 -2
  108. package/src/config/config.ts +24 -5
  109. package/src/config/minimal.ts +9 -0
  110. package/src/config/recommended-strict.ts +9 -0
  111. package/src/config/recommended.ts +9 -0
  112. package/src/config/rules.ts +12 -4
  113. package/src/config/types.ts +15 -2
  114. package/src/config/utils.ts +15 -0
  115. package/src/decorators/async3/index.ts +1 -0
  116. package/src/decorators/common/remove-x-internal.ts +2 -2
  117. package/src/index.ts +2 -1
  118. package/src/lint.ts +26 -3
  119. package/src/oas-types.ts +31 -13
  120. package/src/rules/arazzo/index.ts +1 -1
  121. package/src/rules/async2/index.ts +5 -5
  122. package/src/rules/async3/__tests__/channels-kebab-case.test.ts +141 -0
  123. package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
  124. package/src/rules/async3/channels-kebab-case.ts +19 -0
  125. package/src/rules/async3/index.ts +23 -0
  126. package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
  127. package/src/rules/common/assertions/index.ts +13 -4
  128. package/src/rules/common/spec.ts +2 -2
  129. package/src/rules/oas2/index.ts +4 -4
  130. package/src/rules/oas3/index.ts +39 -37
  131. package/src/types/{asyncapi.ts → asyncapi2.ts} +37 -34
  132. package/src/types/asyncapi3.ts +381 -0
  133. package/src/types/oas3_1.ts +2 -1
  134. package/src/types/redocly-yaml.ts +14 -0
  135. package/src/typings/asyncapi3.ts +61 -0
  136. package/src/utils.ts +5 -3
  137. package/src/visitors.ts +18 -0
  138. package/tsconfig.tsbuildinfo +1 -1
  139. package/lib/types/asyncapi.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @redocly/openapi-core
2
2
 
3
+ ## 1.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added support for AsyncAPI 3.0 description linting.
8
+
9
+ ### Patch Changes
10
+
11
+ - Fixed an issue where `patternProperties` incorrectly caused linting errors due to a missing `PatternProperties` node.
12
+
3
13
  ## 1.18.1
4
14
 
5
15
  ### Patch Changes
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -31,4 +32,3 @@ function measureAsync() {
31
32
  config,
32
33
  });
33
34
  }
34
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -37,4 +38,3 @@ function measureAsync() {
37
38
  config,
38
39
  });
39
40
  }
40
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -18,4 +19,3 @@ function measureAsync() {
18
19
  config,
19
20
  });
20
21
  }
21
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -30,4 +31,3 @@ function measureAsync() {
30
31
  config,
31
32
  });
32
33
  }
33
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -29,4 +30,3 @@ function measureAsync() {
29
30
  config,
30
31
  });
31
32
  }
32
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const fs_1 = require("fs");
5
6
  const path_1 = require("path");
6
7
  const lint_1 = require("../../lint");
@@ -18,4 +19,3 @@ function measureAsync() {
18
19
  config: new config_1.StyleguideConfig((0, config_1.resolvePreset)('recommended', [config_1.defaultPlugin])),
19
20
  });
20
21
  }
21
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureAsync = exports.count = exports.name = void 0;
3
+ exports.count = exports.name = void 0;
4
+ exports.measureAsync = measureAsync;
4
5
  const path = require("path");
5
6
  const fs_1 = require("fs");
6
7
  const resolve_1 = require("../../resolve");
@@ -19,4 +20,3 @@ function measureAsync() {
19
20
  rootType: (0, types_1.normalizeTypes)(oas3_1.Oas3Types).Root,
20
21
  });
21
22
  }
22
- exports.measureAsync = measureAsync;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeConfigForRuleset = exports.parseYamlToDocument = void 0;
3
+ exports.parseYamlToDocument = parseYamlToDocument;
4
+ exports.makeConfigForRuleset = makeConfigForRuleset;
4
5
  const js_yaml_1 = require("../js-yaml");
5
6
  const resolve_1 = require("../resolve");
6
7
  const config_1 = require("../config");
@@ -10,7 +11,6 @@ function parseYamlToDocument(body, absoluteRef = '') {
10
11
  parsed: (0, js_yaml_1.parseYaml)(body, { filename: absoluteRef }),
11
12
  };
12
13
  }
13
- exports.parseYamlToDocument = parseYamlToDocument;
14
14
  function makeConfigForRuleset(rules, plugin) {
15
15
  const rulesConf = {};
16
16
  const ruleId = 'test';
@@ -19,7 +19,11 @@ function makeConfigForRuleset(rules, plugin) {
19
19
  });
20
20
  const extendConfigs = [
21
21
  (0, config_1.resolvePlugins)([
22
- Object.assign(Object.assign({}, plugin), { id: ruleId, rules: { oas3: rules } }),
22
+ {
23
+ ...plugin,
24
+ id: ruleId,
25
+ rules: { oas3: rules },
26
+ },
23
27
  ]),
24
28
  ];
25
29
  if (rules) {
@@ -28,4 +32,3 @@ function makeConfigForRuleset(rules, plugin) {
28
32
  const styleguide = (0, config_1.mergeExtends)(extendConfigs);
29
33
  return new config_1.StyleguideConfig(styleguide);
30
34
  }
31
- exports.makeConfigForRuleset = makeConfigForRuleset;
package/lib/bundle.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import { BaseResolver } from './resolve';
2
2
  import { SpecMajorVersion } from './oas-types';
3
- import type { Oas3Rule } from './visitors';
4
3
  import type { NormalizedNodeType, NodeType } from './types';
5
4
  import type { NormalizedProblem } from './walk';
6
5
  import type { Config, StyleguideConfig } from './config';
7
6
  import type { Document, ResolvedRefMap } from './resolve';
8
- export type Oas3RuleSet = Record<string, Oas3Rule>;
7
+ import type { CollectFn } from './utils';
9
8
  export declare enum OasVersion {
10
9
  Version2 = "oas2",
11
10
  Version3_0 = "oas3_0",
@@ -24,6 +23,7 @@ export declare function bundleConfig(document: Document, resolvedRefMap: Resolve
24
23
  export declare function bundle(opts: {
25
24
  ref?: string;
26
25
  doc?: Document;
26
+ collectSpecData?: CollectFn;
27
27
  } & BundleOptions): Promise<BundleResult>;
28
28
  export declare function bundleFromString(opts: {
29
29
  source: string;
package/lib/bundle.js CHANGED
@@ -1,15 +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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.mapTypeToComponent = exports.bundleDocument = exports.bundleFromString = exports.bundle = exports.bundleConfig = exports.OasVersion = void 0;
3
+ exports.OasVersion = void 0;
4
+ exports.bundleConfig = bundleConfig;
5
+ exports.bundle = bundle;
6
+ exports.bundleFromString = bundleFromString;
7
+ exports.bundleDocument = bundleDocument;
8
+ exports.mapTypeToComponent = mapTypeToComponent;
13
9
  const resolve_1 = require("./resolve");
14
10
  const visitors_1 = require("./visitors");
15
11
  const types_1 = require("./types");
@@ -29,132 +25,130 @@ var OasVersion;
29
25
  OasVersion["Version3_0"] = "oas3_0";
30
26
  OasVersion["Version3_1"] = "oas3_1";
31
27
  })(OasVersion || (exports.OasVersion = OasVersion = {}));
32
- function bundleConfig(document, resolvedRefMap) {
33
- var _a;
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const types = (0, types_1.normalizeTypes)(redocly_yaml_1.ConfigTypes);
36
- const ctx = {
37
- problems: [],
38
- oasVersion: oas_types_1.SpecVersion.OAS3_0,
39
- refTypes: new Map(),
40
- visitorsData: {},
41
- };
42
- const bundleVisitor = (0, visitors_1.normalizeVisitors)([
43
- {
44
- severity: 'error',
45
- ruleId: 'configBundler',
46
- visitor: {
47
- ref: {
48
- leave(node, ctx, resolved) {
49
- replaceRef(node, resolved, ctx);
50
- },
28
+ async function bundleConfig(document, resolvedRefMap) {
29
+ const types = (0, types_1.normalizeTypes)(redocly_yaml_1.ConfigTypes);
30
+ const ctx = {
31
+ problems: [],
32
+ oasVersion: oas_types_1.SpecVersion.OAS3_0,
33
+ refTypes: new Map(),
34
+ visitorsData: {},
35
+ };
36
+ const bundleVisitor = (0, visitors_1.normalizeVisitors)([
37
+ {
38
+ severity: 'error',
39
+ ruleId: 'configBundler',
40
+ visitor: {
41
+ ref: {
42
+ leave(node, ctx, resolved) {
43
+ replaceRef(node, resolved, ctx);
51
44
  },
52
45
  },
53
46
  },
54
- ], types);
55
- (0, walk_1.walkDocument)({
56
- document,
57
- rootType: types.ConfigRoot,
58
- normalizedVisitors: bundleVisitor,
59
- resolvedRefMap,
60
- ctx,
61
- });
62
- return (_a = document.parsed) !== null && _a !== void 0 ? _a : {};
47
+ },
48
+ ], types);
49
+ (0, walk_1.walkDocument)({
50
+ document,
51
+ rootType: types.ConfigRoot,
52
+ normalizedVisitors: bundleVisitor,
53
+ resolvedRefMap,
54
+ ctx,
63
55
  });
56
+ return document.parsed ?? {};
64
57
  }
65
- exports.bundleConfig = bundleConfig;
66
- function bundle(opts) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const { ref, doc, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve), base = null, } = opts;
69
- if (!(ref || doc)) {
70
- throw new Error('Document or reference is required.\n');
71
- }
72
- const document = doc === undefined ? yield externalRefResolver.resolveDocument(base, ref, true) : doc;
73
- if (document instanceof Error) {
74
- throw document;
75
- }
76
- return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.styleguide, externalRefResolver }));
58
+ async function bundle(opts) {
59
+ const { ref, doc, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve), base = null, } = opts;
60
+ if (!(ref || doc)) {
61
+ throw new Error('Document or reference is required.\n');
62
+ }
63
+ const document = doc === undefined ? await externalRefResolver.resolveDocument(base, ref, true) : doc;
64
+ if (document instanceof Error) {
65
+ throw document;
66
+ }
67
+ opts.collectSpecData?.(document.parsed);
68
+ return bundleDocument({
69
+ document,
70
+ ...opts,
71
+ config: opts.config.styleguide,
72
+ externalRefResolver,
77
73
  });
78
74
  }
79
- exports.bundle = bundle;
80
- function bundleFromString(opts) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
83
- const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/');
84
- return bundleDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
75
+ async function bundleFromString(opts) {
76
+ const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
77
+ const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/');
78
+ return bundleDocument({
79
+ document,
80
+ ...opts,
81
+ externalRefResolver,
82
+ config: opts.config.styleguide,
85
83
  });
86
84
  }
87
- exports.bundleFromString = bundleFromString;
88
- function bundleDocument(opts) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
91
- const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
92
- const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
93
- const rules = config.getRulesForOasVersion(specMajorVersion);
94
- const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : (0, oas_types_1.getTypes)(specVersion), specVersion), config);
95
- const preprocessors = (0, rules_1.initRules)(rules, config, 'preprocessors', specVersion);
96
- const decorators = (0, rules_1.initRules)(rules, config, 'decorators', specVersion);
97
- const ctx = {
98
- problems: [],
99
- oasVersion: specVersion,
100
- refTypes: new Map(),
101
- visitorsData: {},
102
- };
103
- if (removeUnusedComponents) {
104
- decorators.push({
105
- severity: 'error',
106
- ruleId: 'remove-unused-components',
107
- visitor: specMajorVersion === oas_types_1.SpecMajorVersion.OAS2
108
- ? (0, remove_unused_components_1.RemoveUnusedComponents)({})
109
- : (0, remove_unused_components_2.RemoveUnusedComponents)({}),
110
- });
111
- }
112
- let resolvedRefMap = yield (0, resolve_1.resolveDocument)({
113
- rootDocument: document,
114
- rootType: types.Root,
115
- externalRefResolver,
85
+ async function bundleDocument(opts) {
86
+ const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
87
+ const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
88
+ const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
89
+ const rules = config.getRulesForOasVersion(specMajorVersion);
90
+ const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes ?? (0, oas_types_1.getTypes)(specVersion), specVersion), config);
91
+ const preprocessors = (0, rules_1.initRules)(rules, config, 'preprocessors', specVersion);
92
+ const decorators = (0, rules_1.initRules)(rules, config, 'decorators', specVersion);
93
+ const ctx = {
94
+ problems: [],
95
+ oasVersion: specVersion,
96
+ refTypes: new Map(),
97
+ visitorsData: {},
98
+ };
99
+ if (removeUnusedComponents) {
100
+ decorators.push({
101
+ severity: 'error',
102
+ ruleId: 'remove-unused-components',
103
+ visitor: specMajorVersion === oas_types_1.SpecMajorVersion.OAS2
104
+ ? (0, remove_unused_components_1.RemoveUnusedComponents)({})
105
+ : (0, remove_unused_components_2.RemoveUnusedComponents)({}),
116
106
  });
117
- if (preprocessors.length > 0) {
118
- // Make additional pass to resolve refs defined in preprocessors.
119
- (0, walk_1.walkDocument)({
120
- document,
121
- rootType: types.Root,
122
- normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
123
- resolvedRefMap,
124
- ctx,
125
- });
126
- resolvedRefMap = yield (0, resolve_1.resolveDocument)({
127
- rootDocument: document,
128
- rootType: types.Root,
129
- externalRefResolver,
130
- });
131
- }
132
- const bundleVisitor = (0, visitors_1.normalizeVisitors)([
133
- {
134
- severity: 'error',
135
- ruleId: 'bundler',
136
- visitor: makeBundleVisitor(specMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
137
- },
138
- ...decorators,
139
- ], types);
107
+ }
108
+ let resolvedRefMap = await (0, resolve_1.resolveDocument)({
109
+ rootDocument: document,
110
+ rootType: types.Root,
111
+ externalRefResolver,
112
+ });
113
+ if (preprocessors.length > 0) {
114
+ // Make additional pass to resolve refs defined in preprocessors.
140
115
  (0, walk_1.walkDocument)({
141
116
  document,
142
117
  rootType: types.Root,
143
- normalizedVisitors: bundleVisitor,
118
+ normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
144
119
  resolvedRefMap,
145
120
  ctx,
146
121
  });
147
- return {
148
- bundle: document,
149
- problems: ctx.problems.map((problem) => config.addProblemToIgnore(problem)),
150
- fileDependencies: externalRefResolver.getFiles(),
122
+ resolvedRefMap = await (0, resolve_1.resolveDocument)({
123
+ rootDocument: document,
151
124
  rootType: types.Root,
152
- refTypes: ctx.refTypes,
153
- visitorsData: ctx.visitorsData,
154
- };
125
+ externalRefResolver,
126
+ });
127
+ }
128
+ const bundleVisitor = (0, visitors_1.normalizeVisitors)([
129
+ {
130
+ severity: 'error',
131
+ ruleId: 'bundler',
132
+ visitor: makeBundleVisitor(specMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
133
+ },
134
+ ...decorators,
135
+ ], types);
136
+ (0, walk_1.walkDocument)({
137
+ document,
138
+ rootType: types.Root,
139
+ normalizedVisitors: bundleVisitor,
140
+ resolvedRefMap,
141
+ ctx,
155
142
  });
143
+ return {
144
+ bundle: document,
145
+ problems: ctx.problems.map((problem) => config.addProblemToIgnore(problem)),
146
+ fileDependencies: externalRefResolver.getFiles(),
147
+ rootType: types.Root,
148
+ refTypes: ctx.refTypes,
149
+ visitorsData: ctx.visitorsData,
150
+ };
156
151
  }
157
- exports.bundleDocument = bundleDocument;
158
152
  function mapTypeToComponent(typeName, version) {
159
153
  switch (version) {
160
154
  case oas_types_1.SpecMajorVersion.OAS3:
@@ -200,6 +194,15 @@ function mapTypeToComponent(typeName, version) {
200
194
  default:
201
195
  return null;
202
196
  }
197
+ case oas_types_1.SpecMajorVersion.Async3:
198
+ switch (typeName) {
199
+ case 'Schema':
200
+ return 'schemas';
201
+ case 'Parameter':
202
+ return 'parameters';
203
+ default:
204
+ return null;
205
+ }
203
206
  case oas_types_1.SpecMajorVersion.Arazzo:
204
207
  switch (typeName) {
205
208
  case 'Root.x-parameters_items':
@@ -211,7 +214,6 @@ function mapTypeToComponent(typeName, version) {
211
214
  }
212
215
  }
213
216
  }
214
- exports.mapTypeToComponent = mapTypeToComponent;
215
217
  function replaceRef(ref, resolved, ctx) {
216
218
  if (!(0, utils_1.isPlainObject)(resolved.node)) {
217
219
  ctx.parent[ctx.key] = resolved.node;
@@ -276,6 +278,9 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
276
278
  else if (version === oas_types_1.SpecMajorVersion.Async2) {
277
279
  components = root.components = root.components || {};
278
280
  }
281
+ else if (version === oas_types_1.SpecMajorVersion.Async3) {
282
+ components = root.components = root.components || {};
283
+ }
279
284
  else if (version === oas_types_1.SpecMajorVersion.Arazzo) {
280
285
  components = root.components = root.components || {};
281
286
  }
@@ -320,14 +325,16 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
320
325
  if (version === oas_types_1.SpecMajorVersion.OAS3) {
321
326
  return `#/components/${componentType}/${name}`;
322
327
  }
328
+ else if (version === oas_types_1.SpecMajorVersion.Async2 || version === oas_types_1.SpecMajorVersion.Async3) {
329
+ return `#/components/${componentType}/${name}`;
330
+ }
323
331
  else {
324
332
  return `#/${componentType}/${name}`;
325
333
  }
326
334
  }
327
335
  function isEqualOrEqualRef(node, target, ctx) {
328
- var _a;
329
336
  if ((0, ref_utils_1.isRef)(node) &&
330
- ((_a = ctx.resolve(node, rootLocation.absolutePointer).location) === null || _a === void 0 ? void 0 : _a.absolutePointer) ===
337
+ ctx.resolve(node, rootLocation.absolutePointer).location?.absolutePointer ===
331
338
  target.location.absolutePointer) {
332
339
  return true;
333
340
  }
package/lib/config/all.js CHANGED
@@ -114,6 +114,15 @@ const all = {
114
114
  'channels-kebab-case': 'error',
115
115
  'no-channel-trailing-slash': 'error',
116
116
  },
117
+ async3Rules: {
118
+ spec: 'error',
119
+ 'info-contact': 'error',
120
+ 'operation-operationId': 'error',
121
+ 'tag-description': 'error',
122
+ 'tags-alphabetical': 'error',
123
+ 'channels-kebab-case': 'error',
124
+ 'no-channel-trailing-slash': 'error',
125
+ },
117
126
  arazzoRules: { spec: 'error' },
118
127
  };
119
128
  exports.default = all;
@@ -8,14 +8,17 @@ const minimal_1 = require("./minimal");
8
8
  const oas3_1 = require("../rules/oas3");
9
9
  const oas2_1 = require("../rules/oas2");
10
10
  const async2_1 = require("../rules/async2");
11
+ const async3_1 = require("../rules/async3");
11
12
  const arazzo_1 = require("../rules/arazzo");
12
13
  const oas3_2 = require("../rules/oas3");
13
14
  const oas2_2 = require("../rules/oas2");
14
15
  const async2_2 = require("../rules/async2");
16
+ const async3_2 = require("../rules/async3");
15
17
  const arazzo_2 = require("../rules/arazzo");
16
18
  const oas3_3 = require("../decorators/oas3");
17
19
  const oas2_3 = require("../decorators/oas2");
18
20
  const async2_3 = require("../decorators/async2");
21
+ const async3_3 = require("../decorators/async3");
19
22
  const arazzo_3 = require("../decorators/arazzo");
20
23
  exports.builtInConfigs = {
21
24
  recommended: recommended_1.default,
@@ -27,23 +30,26 @@ exports.builtInConfigs = {
27
30
  },
28
31
  };
29
32
  exports.defaultPlugin = {
30
- id: '',
33
+ id: '', // default plugin doesn't have id
31
34
  rules: {
32
35
  oas3: oas3_1.rules,
33
36
  oas2: oas2_1.rules,
34
37
  async2: async2_1.rules,
38
+ async3: async3_1.rules,
35
39
  arazzo: arazzo_1.rules,
36
40
  },
37
41
  preprocessors: {
38
42
  oas3: oas3_2.preprocessors,
39
43
  oas2: oas2_2.preprocessors,
40
44
  async2: async2_2.preprocessors,
45
+ async3: async3_2.preprocessors,
41
46
  arazzo: arazzo_2.preprocessors,
42
47
  },
43
48
  decorators: {
44
49
  oas3: oas3_3.decorators,
45
50
  oas2: oas2_3.decorators,
46
51
  async2: async2_3.decorators,
52
+ async3: async3_3.decorators,
47
53
  arazzo: arazzo_3.decorators,
48
54
  },
49
55
  configs: exports.builtInConfigs,