@redocly/openapi-core 1.1.0 → 1.2.1

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 (77) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +250 -7
  3. package/lib/bundle.d.ts +12 -6
  4. package/lib/bundle.js +34 -24
  5. package/lib/config/builtIn.js +4 -0
  6. package/lib/config/config-resolvers.js +19 -6
  7. package/lib/config/config.d.ts +9 -9
  8. package/lib/config/config.js +32 -17
  9. package/lib/config/load.d.ts +3 -2
  10. package/lib/config/load.js +2 -2
  11. package/lib/config/rules.d.ts +2 -2
  12. package/lib/config/types.d.ts +10 -3
  13. package/lib/index.d.ts +4 -3
  14. package/lib/index.js +10 -6
  15. package/lib/lint.js +10 -16
  16. package/lib/oas-types.d.ts +16 -10
  17. package/lib/oas-types.js +52 -26
  18. package/lib/rules/async2/channels-kebab-case.d.ts +2 -0
  19. package/lib/rules/async2/channels-kebab-case.js +19 -0
  20. package/lib/rules/async2/index.d.ts +12 -0
  21. package/lib/rules/async2/index.js +22 -0
  22. package/lib/rules/async2/no-channel-trailing-slash.d.ts +2 -0
  23. package/lib/rules/async2/no-channel-trailing-slash.js +16 -0
  24. package/lib/rules/common/assertions/asserts.js +12 -4
  25. package/lib/rules/common/scalar-property-missing-example.js +1 -1
  26. package/lib/rules/common/spec.d.ts +2 -2
  27. package/lib/rules/common/spec.js +3 -3
  28. package/lib/rules/oas2/index.js +1 -1
  29. package/lib/rules/oas3/index.js +1 -1
  30. package/lib/rules/oas3/no-server-example.com.js +3 -2
  31. package/lib/types/asyncapi.d.ts +2 -0
  32. package/lib/types/asyncapi.js +1034 -0
  33. package/lib/types/oas3_1.js +8 -1
  34. package/lib/types/redocly-yaml.js +3 -0
  35. package/lib/typings/asyncapi.d.ts +21 -0
  36. package/lib/typings/asyncapi.js +2 -0
  37. package/lib/visitors.d.ts +12 -0
  38. package/lib/walk.d.ts +3 -3
  39. package/package.json +4 -2
  40. package/src/__tests__/__snapshots__/bundle.test.ts.snap +1 -1
  41. package/src/__tests__/bundle.test.ts +65 -25
  42. package/src/__tests__/fixtures/lint/openapi.yaml +10 -0
  43. package/src/__tests__/fixtures/redocly.yaml +2 -0
  44. package/src/__tests__/lint.test.ts +67 -8
  45. package/src/bundle.ts +62 -35
  46. package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
  47. package/src/config/__tests__/config.test.ts +15 -4
  48. package/src/config/__tests__/load.test.ts +35 -2
  49. package/src/config/builtIn.ts +4 -0
  50. package/src/config/config-resolvers.ts +25 -6
  51. package/src/config/config.ts +51 -27
  52. package/src/config/load.ts +11 -4
  53. package/src/config/rules.ts +2 -2
  54. package/src/config/types.ts +17 -4
  55. package/src/index.ts +10 -2
  56. package/src/lint.ts +13 -22
  57. package/src/oas-types.ts +59 -21
  58. package/src/rules/async2/__tests__/channels-kebab-case.test.ts +141 -0
  59. package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +97 -0
  60. package/src/rules/async2/channels-kebab-case.ts +18 -0
  61. package/src/rules/async2/index.ts +22 -0
  62. package/src/rules/async2/no-channel-trailing-slash.ts +15 -0
  63. package/src/rules/common/assertions/asserts.ts +16 -4
  64. package/src/rules/common/scalar-property-missing-example.ts +2 -2
  65. package/src/rules/common/spec.ts +2 -2
  66. package/src/rules/oas2/index.ts +2 -2
  67. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +36 -1
  68. package/src/rules/oas3/__tests__/spec/spec.test.ts +1 -1
  69. package/src/rules/oas3/index.ts +2 -2
  70. package/src/rules/oas3/no-server-example.com.ts +3 -2
  71. package/src/types/asyncapi.ts +1142 -0
  72. package/src/types/oas3_1.ts +7 -1
  73. package/src/types/redocly-yaml.ts +3 -0
  74. package/src/typings/asyncapi.ts +26 -0
  75. package/src/visitors.ts +22 -0
  76. package/src/walk.ts +3 -3
  77. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @redocly/openapi-core
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed an issue with nested refs in the `join` command.
8
+ - Fixed pattern for no-server-example.com rule to improve detection accuracy.
9
+ - Changed the report location for `pattern` and `notPattern` assertions to be more precise.
10
+ - Updated `unevaluatedItems` type definition to resolve either boolean or object schema per JSON Schema 2019-09 specification.
11
+ - Enhanced public API by small typescript typing fix and exporting new function `bundleFromString`.
12
+
13
+ ## 1.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Added support for linting AsyncAPI v2 files, so that a wider range of API descriptions can use the Redocly linting workflow.
18
+
19
+ ### Patch Changes
20
+
21
+ - Renamed API definition to API description for consistency.
22
+
3
23
  ## 1.1.0
4
24
 
5
25
  ### Minor Changes
package/README.md CHANGED
@@ -2,24 +2,267 @@
2
2
 
3
3
  See https://github.com/Redocly/redocly-cli
4
4
 
5
+ > [!IMPORTANT]
6
+ The `openapi-core package` is designed for our internal use; the interfaces that are considered safe to use are documented below.
7
+ Some of the function arguments are not documented below because they are not intended for public use.
8
+ Avoid using any functions or features that are not documented below.
9
+ If your use case is not documented below, please open an issue.
10
+
5
11
  ## Basic usage
6
12
 
7
- ### Lint
13
+ ### Lint from file system
14
+
15
+ [Lint](https://redocly.com/docs/cli/commands/lint/) a file, optionally with a [config file](https://redocly.com/docs/cli/configuration/).
8
16
 
9
17
  ```js
10
- import { formatProblems, lint, loadConfig } from '@redocly/openapi-core';
18
+ import { lint, loadConfig } from '@redocly/openapi-core';
11
19
 
12
20
  const pathToApi = 'openapi.yaml';
13
- const config = loadConfig({ configPath: 'optional/path/to/.redocly.yaml' });
21
+ const config = await loadConfig({ configPath: 'optional/path/to/redocly.yaml' });
14
22
  const lintResults = await lint({ ref: pathToApi, config });
15
23
  ```
16
24
 
17
- ### Bundle
25
+ The content of `lintResults` describes any errors or warnings found during linting; an empty array means no problems were found.
26
+ For each problem, the rule, severity, feedback message and a location object are provided.
27
+ To learn more, [check the `lint` function section](#lint).
28
+
29
+ ### Bundle from file system
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/).
18
32
 
19
33
  ```js
20
- import { formatProblems, bundle, loadConfig } from '@redocly/openapi-core';
34
+ import { bundle, loadConfig } from '@redocly/openapi-core';
21
35
 
22
36
  const pathToApi = 'openapi.yaml';
23
- const config = loadConfig({ configPath: 'optional/path/to/.redocly.yaml' });
24
- const { bundle, problems } = await bundle({ ref: pathToApi, config });
37
+ const config = await loadConfig({ configPath: 'optional/path/to/redocly.yaml' });
38
+ const bundleResults = await bundle({ ref: pathToApi, config });
39
+ ```
40
+
41
+ In `bundleResults`, the `bundle.parsed` field has the bundled API description.
42
+ For more information, [check the `bundle` function section](#bundle).
43
+
44
+ ### Lint from memory with config
45
+
46
+ [Lint](https://redocly.com/docs/cli/commands/lint/) an API description, with configuration defined. This is useful if the API description you're working with isn't a file on disk.
47
+
48
+ ```js
49
+ import { lintFromString, createConfig, stringifyYaml } from '@redocly/openapi-core';
50
+
51
+ const config = await createConfig(
52
+ {
53
+ extends: ['minimal'],
54
+ rules: {
55
+ 'operation-description': 'error',
56
+ },
57
+ },
58
+ {
59
+ // optionally provide config path for resolving $refs and proper error locations
60
+ configPath: 'optional/path/to/redocly.yaml',
61
+ }
62
+ );
63
+ const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
64
+ const lintResults = await lintFromString({
65
+ source,
66
+ // optionally pass path to the file for resolving $refs and proper error locations
67
+ absoluteRef: 'optional/path/to/openapi.yaml',
68
+ config,
69
+ });
70
+ ```
71
+
72
+ ### Lint from memory with a custom plugin
73
+
74
+ [Lint](https://redocly.com/docs/cli/commands/lint/) an API description, with configuration including a [custom plugin](https://redocly.com/docs/cli/custom-plugins/) to define a rule.
75
+
76
+ ```js
77
+ import { lintFromString, createConfig, stringifyYaml } from '@redocly/openapi-core';
78
+
79
+ const CustomRule = (ruleOptions) => {
80
+ return {
81
+ Operation() {
82
+ // some rule logic
83
+ },
84
+ };
85
+ };
86
+
87
+ const config = await createConfig({
88
+ extends: ['recommended'],
89
+ plugins: [
90
+ {
91
+ id: 'pluginId',
92
+ rules: {
93
+ oas3: {
94
+ customRule1: CustomRule,
95
+ },
96
+ oas2: {
97
+ customRule1: CustomRule, // if the same rule can handle both oas3 and oas2
98
+ },
99
+ },
100
+ decorators: {
101
+ // ...
102
+ },
103
+ },
104
+ ],
105
+ // enable rule
106
+ rules: {
107
+ 'pluginId/customRule1': 'error',
108
+ },
109
+ decorators: {
110
+ // ...
111
+ },
112
+ });
113
+
114
+ const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
115
+ const lintResults = await lintFromString({
116
+ source,
117
+ // optionally pass path to the file for resolving $refs and proper error locations
118
+ absoluteRef: 'optional/path/to/openapi.yaml',
119
+ config,
120
+ });
121
+ ```
122
+
123
+ ### Bundle from memory
124
+
125
+ [Bundle](https://redocly.com/docs/cli/commands/bundle/) an API description into a single structure, using default configuration.
126
+
127
+ ```js
128
+ import { bundleFromString, createConfig } from '@redocly/openapi-core';
129
+
130
+ const config = await createConfig({}); // create empty config
131
+ const source = stringifyYaml({ openapi: '3.0.1' /* ... */ }); // you can also use JSON.stringify
132
+ const bundleResults = await bundleFromString({
133
+ source,
134
+ // optionally pass path to the file for resolving $refs and proper error locations
135
+ absoluteRef: 'optional/path/to/openapi.yaml',
136
+ config,
137
+ });
25
138
  ```
139
+
140
+ ## API
141
+
142
+ ### `createConfig`
143
+
144
+ Creates a config object from a JSON or YAML string or JS object.
145
+ Resolves remote config from `extends` (if there are URLs or local fs paths).
146
+
147
+ ```ts
148
+ async function createConfig(
149
+ // JSON or YAML string or object with Redocly config
150
+ config: string | RawUniversalConfig,
151
+ options?: {
152
+ // optional path to the config file for resolving $refs and proper error locations
153
+ configPath?: string;
154
+ }
155
+ ): Promise<Config>;
156
+ ```
157
+
158
+ ### `loadConfig`
159
+
160
+ Loads a config object from a file system. If `configPath` is not provided,
161
+ it tries to find `redocly.yaml` in the current working directory.
162
+
163
+ ```ts
164
+ async function loadConfig(options?: {
165
+ // optional path to the config file for resolving $refs and proper error locations
166
+ configPath?: string;
167
+ // allows to add custom `extends` additionally to one from the config file
168
+ customExtends?: string[];
169
+ }): Promise<Config>;
170
+ ```
171
+
172
+ ### `lint`
173
+
174
+ Lint an OpenAPI document from the file system.
175
+
176
+ ```ts
177
+ async function lint(options: {
178
+ // path to the OpenAPI document root
179
+ ref: string;
180
+ // config object
181
+ config: Config;
182
+ }): Promise<NormalizedProblem[]>;
183
+ ```
184
+
185
+ ### `lintFromString`
186
+
187
+ Lint an OpenAPI document from a string.
188
+
189
+ ```ts
190
+ async function lintFromString(options: {
191
+ // OpenAPI document string
192
+ source: string;
193
+ // optional path to the OpenAPI document for resolving $refs and proper error locations
194
+ absoluteRef?: string;
195
+ // config object
196
+ config: Config;
197
+ }): Promise<NormalizedProblem[]>;
198
+ ```
199
+
200
+ ### `bundle`
201
+
202
+ Bundle an OpenAPI document from the file system.
203
+
204
+ ```ts
205
+ async function bundle(options: {
206
+ // path to the OpenAPI document root
207
+ ref: string;
208
+ // config object
209
+ config: Config;
210
+ // whether to fully dereference $refs, resulting document won't have any $ref
211
+ // warning: this can produce circular objects
212
+ dereference?: boolean;
213
+ // whether to remove unused components (schemas, parameters, responses, etc)
214
+ removeUnusedComponents?: boolean;
215
+ // whether to keep $ref pointers to the http URLs and resolve only local fs $refs
216
+ keepUrlRefs?: boolean;
217
+ }): Promise<{
218
+ bundle: {
219
+ parsed: object; // OpenAPI document object as js object
220
+ };
221
+ problems: NormalizedProblem[]
222
+ fileDependencies
223
+ rootType
224
+ refTypes
225
+ visitorsData
226
+
227
+ }>;
228
+ ```
229
+
230
+ ### `bundleFromString`
231
+
232
+ Bundle an OpenAPI document from a string.
233
+
234
+ ```ts
235
+ async function bundleFromString(options: {
236
+ // OpenAPI document string
237
+ source: string;
238
+ // optional path to the OpenAPI document for resolving $refs and proper error locations
239
+ absoluteRef?: string;
240
+ // config object
241
+ config: Config;
242
+ // whether to fully dereference $refs, resulting document won't have any $ref
243
+ // warning: this can produce circular objects
244
+ dereference?: boolean;
245
+ // whether to remove unused components (schemas, parameters, responses, etc)
246
+ removeUnusedComponents?: boolean;
247
+ // whether to keep $ref pointers to the http URLs and resolve only local fs $refs
248
+ keepUrlRefs?: boolean;
249
+ }): Promise<{
250
+ bundle: {
251
+ parsed: object; // OpenAPI document object as js object
252
+ };
253
+ problems: NormalizedProblem[]
254
+ fileDependencies
255
+ rootType
256
+ refTypes
257
+ visitorsData
258
+
259
+ }>;
260
+ ```
261
+
262
+ ### `stringifyYaml`
263
+
264
+ Helper function to stringify a javascript object to YAML.
265
+
266
+ ```ts
267
+ function stringifyYaml(obj: object): string;
268
+ ```
package/lib/bundle.d.ts CHANGED
@@ -2,7 +2,7 @@ import { BaseResolver, Document } from './resolve';
2
2
  import { Oas3Rule } from './visitors';
3
3
  import { NormalizedNodeType, NodeType } from './types';
4
4
  import { NormalizedProblem } from './walk';
5
- import { OasMajorVersion } from './oas-types';
5
+ import { SpecMajorVersion } from './oas-types';
6
6
  import type { Config, StyleguideConfig } from './config';
7
7
  export declare type Oas3RuleSet = Record<string, Oas3Rule>;
8
8
  export declare enum OasVersion {
@@ -10,9 +10,7 @@ export declare enum OasVersion {
10
10
  Version3_0 = "oas3_0",
11
11
  Version3_1 = "oas3_1"
12
12
  }
13
- export declare function bundle(opts: {
14
- ref?: string;
15
- doc?: Document;
13
+ export declare type BundleOptions = {
16
14
  externalRefResolver?: BaseResolver;
17
15
  config: Config;
18
16
  dereference?: boolean;
@@ -20,7 +18,15 @@ export declare function bundle(opts: {
20
18
  skipRedoclyRegistryRefs?: boolean;
21
19
  removeUnusedComponents?: boolean;
22
20
  keepUrlRefs?: boolean;
23
- }): Promise<BundleResult>;
21
+ };
22
+ export declare function bundle(opts: {
23
+ ref?: string;
24
+ doc?: Document;
25
+ } & BundleOptions): Promise<BundleResult>;
26
+ export declare function bundleFromString(opts: {
27
+ source: string;
28
+ absoluteRef?: string;
29
+ } & BundleOptions): Promise<BundleResult>;
24
30
  export declare type BundleResult = {
25
31
  bundle: Document;
26
32
  problems: NormalizedProblem[];
@@ -39,4 +45,4 @@ export declare function bundleDocument(opts: {
39
45
  removeUnusedComponents?: boolean;
40
46
  keepUrlRefs?: boolean;
41
47
  }): Promise<BundleResult>;
42
- export declare function mapTypeToComponent(typeName: string, version: OasMajorVersion): "parameters" | "examples" | "headers" | "schemas" | "responses" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | "definitions" | null;
48
+ export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "responses" | "parameters" | "examples" | "headers" | "schemas" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | "definitions" | null;
package/lib/bundle.js CHANGED
@@ -9,13 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.OasVersion = void 0;
12
+ exports.mapTypeToComponent = exports.bundleDocument = exports.bundleFromString = exports.bundle = exports.OasVersion = void 0;
13
13
  const isEqual = require("lodash.isequal");
14
14
  const resolve_1 = require("./resolve");
15
15
  const visitors_1 = require("./visitors");
16
- const oas3_1 = require("./types/oas3");
17
- const oas2_1 = require("./types/oas2");
18
- const oas3_1_1 = require("./types/oas3_1");
19
16
  const types_1 = require("./types");
20
17
  const walk_1 = require("./walk");
21
18
  const oas_types_1 = require("./oas-types");
@@ -38,7 +35,7 @@ function bundle(opts) {
38
35
  if (!(ref || doc)) {
39
36
  throw new Error('Document or reference is required.\n');
40
37
  }
41
- const document = doc !== undefined ? doc : yield externalRefResolver.resolveDocument(base, ref, true);
38
+ const document = doc === undefined ? yield externalRefResolver.resolveDocument(base, ref, true) : doc;
42
39
  if (document instanceof Error) {
43
40
  throw document;
44
41
  }
@@ -46,22 +43,26 @@ function bundle(opts) {
46
43
  });
47
44
  }
48
45
  exports.bundle = bundle;
46
+ function bundleFromString(opts) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
49
+ const document = resolve_1.makeDocumentFromString(source, absoluteRef || '/');
50
+ return bundleDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
51
+ });
52
+ }
53
+ exports.bundleFromString = bundleFromString;
49
54
  function bundleDocument(opts) {
50
55
  return __awaiter(this, void 0, void 0, function* () {
51
56
  const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
52
- const oasVersion = oas_types_1.detectOpenAPI(document.parsed);
53
- const oasMajorVersion = oas_types_1.openAPIMajor(oasVersion);
54
- const rules = config.getRulesForOasVersion(oasMajorVersion);
55
- const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3)
56
- ? oasVersion === OasVersion.Version3_1
57
- ? oas3_1_1.Oas3_1Types
58
- : oas3_1.Oas3Types
59
- : oas2_1.Oas2Types, oasVersion), config);
60
- const preprocessors = rules_1.initRules(rules, config, 'preprocessors', oasVersion);
61
- const decorators = rules_1.initRules(rules, config, 'decorators', oasVersion);
57
+ const specVersion = oas_types_1.detectSpec(document.parsed);
58
+ const specMajorVersion = oas_types_1.getMajorSpecVersion(specVersion);
59
+ const rules = config.getRulesForOasVersion(specMajorVersion);
60
+ const types = types_1.normalizeTypes(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : oas_types_1.getTypes(specVersion), specVersion), config);
61
+ const preprocessors = rules_1.initRules(rules, config, 'preprocessors', specVersion);
62
+ const decorators = rules_1.initRules(rules, config, 'decorators', specVersion);
62
63
  const ctx = {
63
64
  problems: [],
64
- oasVersion: oasVersion,
65
+ oasVersion: specVersion,
65
66
  refTypes: new Map(),
66
67
  visitorsData: {},
67
68
  };
@@ -69,7 +70,7 @@ function bundleDocument(opts) {
69
70
  decorators.push({
70
71
  severity: 'error',
71
72
  ruleId: 'remove-unused-components',
72
- visitor: oasMajorVersion === oas_types_1.OasMajorVersion.Version2
73
+ visitor: specMajorVersion === oas_types_1.SpecMajorVersion.OAS2
73
74
  ? remove_unused_components_1.RemoveUnusedComponents({})
74
75
  : remove_unused_components_2.RemoveUnusedComponents({}),
75
76
  });
@@ -98,7 +99,7 @@ function bundleDocument(opts) {
98
99
  {
99
100
  severity: 'error',
100
101
  ruleId: 'bundler',
101
- visitor: makeBundleVisitor(oasMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
102
+ visitor: makeBundleVisitor(specMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
102
103
  },
103
104
  ...decorators,
104
105
  ], types);
@@ -122,7 +123,7 @@ function bundleDocument(opts) {
122
123
  exports.bundleDocument = bundleDocument;
123
124
  function mapTypeToComponent(typeName, version) {
124
125
  switch (version) {
125
- case oas_types_1.OasMajorVersion.Version3:
126
+ case oas_types_1.SpecMajorVersion.OAS3:
126
127
  switch (typeName) {
127
128
  case 'Schema':
128
129
  return 'schemas';
@@ -145,7 +146,7 @@ function mapTypeToComponent(typeName, version) {
145
146
  default:
146
147
  return null;
147
148
  }
148
- case oas_types_1.OasMajorVersion.Version2:
149
+ case oas_types_1.SpecMajorVersion.OAS2:
149
150
  switch (typeName) {
150
151
  case 'Schema':
151
152
  return 'definitions';
@@ -156,6 +157,15 @@ function mapTypeToComponent(typeName, version) {
156
157
  default:
157
158
  return null;
158
159
  }
160
+ case oas_types_1.SpecMajorVersion.Async2:
161
+ switch (typeName) {
162
+ case 'Schema':
163
+ return 'schemas';
164
+ case 'Parameter':
165
+ return 'parameters';
166
+ default:
167
+ return null;
168
+ }
159
169
  }
160
170
  }
161
171
  exports.mapTypeToComponent = mapTypeToComponent;
@@ -202,16 +212,16 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
202
212
  Root: {
203
213
  enter(root, ctx) {
204
214
  rootLocation = ctx.location;
205
- if (version === oas_types_1.OasMajorVersion.Version3) {
215
+ if (version === oas_types_1.SpecMajorVersion.OAS3) {
206
216
  components = root.components = root.components || {};
207
217
  }
208
- else if (version === oas_types_1.OasMajorVersion.Version2) {
218
+ else if (version === oas_types_1.SpecMajorVersion.OAS2) {
209
219
  components = root;
210
220
  }
211
221
  },
212
222
  },
213
223
  };
214
- if (version === oas_types_1.OasMajorVersion.Version3) {
224
+ if (version === oas_types_1.SpecMajorVersion.OAS3) {
215
225
  visitor.DiscriminatorMapping = {
216
226
  leave(mapping, ctx) {
217
227
  for (const name of Object.keys(mapping)) {
@@ -259,7 +269,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
259
269
  components[componentType] = components[componentType] || {};
260
270
  const name = getComponentName(target, componentType, ctx);
261
271
  components[componentType][name] = target.node;
262
- if (version === oas_types_1.OasMajorVersion.Version3) {
272
+ if (version === oas_types_1.SpecMajorVersion.OAS3) {
263
273
  return `#/components/${componentType}/${name}`;
264
274
  }
265
275
  else {
@@ -6,6 +6,7 @@ const all_1 = require("./all");
6
6
  const minimal_1 = require("./minimal");
7
7
  const oas3_1 = require("../rules/oas3");
8
8
  const oas2_1 = require("../rules/oas2");
9
+ const async2_1 = require("../rules/async2");
9
10
  const oas3_2 = require("../rules/oas3");
10
11
  const oas2_2 = require("../rules/oas2");
11
12
  const oas3_3 = require("../decorators/oas3");
@@ -23,14 +24,17 @@ exports.defaultPlugin = {
23
24
  rules: {
24
25
  oas3: oas3_1.rules,
25
26
  oas2: oas2_1.rules,
27
+ async2: async2_1.rules,
26
28
  },
27
29
  preprocessors: {
28
30
  oas3: oas3_2.preprocessors,
29
31
  oas2: oas2_2.preprocessors,
32
+ async2: {},
30
33
  },
31
34
  decorators: {
32
35
  oas3: oas3_3.decorators,
33
36
  oas2: oas2_3.decorators,
37
+ async2: {},
34
38
  },
35
39
  configs: exports.builtInConfigs,
36
40
  };
@@ -105,8 +105,8 @@ function resolvePlugins(plugins, configPath = '') {
105
105
  seenPluginIds.set(id, p.toString());
106
106
  const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
107
107
  if (pluginModule.rules) {
108
- if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2) {
109
- throw new Error(`Plugin rules must have \`oas3\` or \`oas2\` rules "${p}.`);
108
+ if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2 && !pluginModule.rules.async2) {
109
+ throw new Error(`Plugin rules must have \`oas3\`, \`oas2\` or \`async2\` rules "${p}.`);
110
110
  }
111
111
  plugin.rules = {};
112
112
  if (pluginModule.rules.oas3) {
@@ -115,10 +115,15 @@ function resolvePlugins(plugins, configPath = '') {
115
115
  if (pluginModule.rules.oas2) {
116
116
  plugin.rules.oas2 = utils_2.prefixRules(pluginModule.rules.oas2, id);
117
117
  }
118
+ if (pluginModule.rules.async2) {
119
+ plugin.rules.async2 = utils_2.prefixRules(pluginModule.rules.async2, id);
120
+ }
118
121
  }
119
122
  if (pluginModule.preprocessors) {
120
- if (!pluginModule.preprocessors.oas3 && !pluginModule.preprocessors.oas2) {
121
- throw new Error(`Plugin \`preprocessors\` must have \`oas3\` or \`oas2\` preprocessors "${p}.`);
123
+ if (!pluginModule.preprocessors.oas3 &&
124
+ !pluginModule.preprocessors.oas2 &&
125
+ !pluginModule.preprocessors.async2) {
126
+ throw new Error(`Plugin \`preprocessors\` must have \`oas3\`, \`oas2\` or \`async2\` preprocessors "${p}.`);
122
127
  }
123
128
  plugin.preprocessors = {};
124
129
  if (pluginModule.preprocessors.oas3) {
@@ -127,10 +132,15 @@ function resolvePlugins(plugins, configPath = '') {
127
132
  if (pluginModule.preprocessors.oas2) {
128
133
  plugin.preprocessors.oas2 = utils_2.prefixRules(pluginModule.preprocessors.oas2, id);
129
134
  }
135
+ if (pluginModule.preprocessors.async2) {
136
+ plugin.preprocessors.async2 = utils_2.prefixRules(pluginModule.preprocessors.async2, id);
137
+ }
130
138
  }
131
139
  if (pluginModule.decorators) {
132
- if (!pluginModule.decorators.oas3 && !pluginModule.decorators.oas2) {
133
- throw new Error(`Plugin \`decorators\` must have \`oas3\` or \`oas2\` decorators "${p}.`);
140
+ if (!pluginModule.decorators.oas3 &&
141
+ !pluginModule.decorators.oas2 &&
142
+ !pluginModule.decorators.async2) {
143
+ throw new Error(`Plugin \`decorators\` must have \`oas3\`, \`oas2\` or \`async2\` decorators "${p}.`);
134
144
  }
135
145
  plugin.decorators = {};
136
146
  if (pluginModule.decorators.oas3) {
@@ -139,6 +149,9 @@ function resolvePlugins(plugins, configPath = '') {
139
149
  if (pluginModule.decorators.oas2) {
140
150
  plugin.decorators.oas2 = utils_2.prefixRules(pluginModule.decorators.oas2, id);
141
151
  }
152
+ if (pluginModule.decorators.async2) {
153
+ plugin.decorators.async2 = utils_2.prefixRules(pluginModule.decorators.async2, id);
154
+ }
142
155
  }
143
156
  if (pluginModule.assertions) {
144
157
  plugin.assertions = pluginModule.assertions;
@@ -1,5 +1,5 @@
1
1
  import { NormalizedProblem } from '../walk';
2
- import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
2
+ import { SpecVersion, SpecMajorVersion, Oas2RuleSet, Oas3RuleSet, Async2RuleSet } 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";
@@ -15,9 +15,9 @@ export declare class StyleguideConfig {
15
15
  plugins: Plugin[];
16
16
  ignore: Record<string, Record<string, Set<string>>>;
17
17
  doNotResolveExamples: boolean;
18
- rules: Record<OasVersion, Record<string, RuleConfig>>;
19
- preprocessors: Record<OasVersion, Record<string, PreprocessorConfig>>;
20
- decorators: Record<OasVersion, Record<string, DecoratorConfig>>;
18
+ rules: Record<SpecVersion, Record<string, RuleConfig>>;
19
+ preprocessors: Record<SpecVersion, Record<string, PreprocessorConfig>>;
20
+ decorators: Record<SpecVersion, Record<string, DecoratorConfig>>;
21
21
  private _usedRules;
22
22
  private _usedVersions;
23
23
  recommendedFallback: boolean;
@@ -28,16 +28,16 @@ export declare class StyleguideConfig {
28
28
  saveIgnore(): void;
29
29
  addIgnore(problem: NormalizedProblem): void;
30
30
  addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
31
- extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
32
- getRuleSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
33
- getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
34
- getDecoratorSettings(ruleId: string, oasVersion: OasVersion): RuleSettings;
31
+ extendTypes(types: Record<string, NodeType>, version: SpecVersion): Record<string, NodeType>;
32
+ getRuleSettings(ruleId: string, oasVersion: SpecVersion): RuleSettings;
33
+ getPreprocessorSettings(ruleId: string, oasVersion: SpecVersion): RuleSettings;
34
+ getDecoratorSettings(ruleId: string, oasVersion: SpecVersion): RuleSettings;
35
35
  getUnusedRules(): {
36
36
  rules: string[];
37
37
  preprocessors: string[];
38
38
  decorators: string[];
39
39
  };
40
- getRulesForOasVersion(version: OasMajorVersion): Oas3RuleSet[] | Oas2RuleSet[];
40
+ getRulesForOasVersion(version: SpecMajorVersion): Oas3RuleSet[] | Oas2RuleSet[] | Async2RuleSet[];
41
41
  skipRules(rules?: string[]): void;
42
42
  skipPreprocessors(preprocessors?: string[]): void;
43
43
  skipDecorators(decorators?: string[]): void;